getMedia method
Implementation
Future<void> getMedia(String accessToken, String mediaId) async {
final Uri uri = Uri.parse('$url$mediaId');
try {
final http.Response res = await http.get(
uri,
headers: {
'Authorization': 'Bearer $accessToken',
},
);
response = res.body;
httpCode = res.statusCode;
final Map<String, dynamic> jsonResponse = jsonDecode(response!);
errorMessage = jsonResponse['error']?['message'];
mediaFileSize = jsonResponse['file_size']?.toString() ?? '';
mediaMimeType = jsonResponse['mime_type'] ?? '';
mediaSha256 = jsonResponse['sha256'] ?? '';
mediaUrl = jsonResponse['url'] ?? '';
mediaId = jsonResponse['id'] ?? '';
if (res.statusCode >= 400) {
error = res.reasonPhrase;
}
} catch (e) {
error = e.toString();
}
}