Created
July 10, 2020 17:51
-
-
Save GursheeshSingh/1e5006d71edd0fe488dbd52a6d47afa9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class GenerateImageUrl { | |
bool success; | |
String message; | |
bool isGenerated; | |
String uploadUrl; | |
String downloadUrl; | |
Future<void> call(String fileType) async { | |
try { | |
Map body = {"fileType": fileType}; | |
var response = await http.post( | |
'http://${Platform.isIOS ? 'localhost' : '10.0.2.2'}:5000/generatePresignedUrl', | |
body: body, | |
); | |
var result = jsonDecode(response.body); | |
if (result['success'] != null) { | |
success = result['success']; | |
message = result['message']; | |
if (response.statusCode == 201) { | |
isGenerated = true; | |
uploadUrl = result["uploadUrl"]; | |
downloadUrl = result["downloadUrl"]; | |
} | |
} | |
} catch (e) { | |
throw ('Error getting url'); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment