Skip to content

Instantly share code, notes, and snippets.

@GursheeshSingh
Created July 10, 2020 17:51
Show Gist options
  • Save GursheeshSingh/1e5006d71edd0fe488dbd52a6d47afa9 to your computer and use it in GitHub Desktop.
Save GursheeshSingh/1e5006d71edd0fe488dbd52a6d47afa9 to your computer and use it in GitHub Desktop.
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