add await for file download
This commit is contained in:
parent
2d72315584
commit
449640699f
|
@ -79,14 +79,14 @@ Future<void> _postOnMastodon(reqJson) async {
|
||||||
final photos =
|
final photos =
|
||||||
attachments.where((attachment) => attachment['type'] == 'photo');
|
attachments.where((attachment) => attachment['type'] == 'photo');
|
||||||
|
|
||||||
final photoUrls = photos.map((photo) {
|
final photoUrls = photos.map((photo) async {
|
||||||
final photoUrl = photo['photo']['sizes'].last['url'];
|
final photoUrl = photo['photo']['sizes'].last['url'];
|
||||||
// Generate a random filename.
|
// Generate a random filename.
|
||||||
// Add the extension '.jpg'.
|
// Add the extension '.jpg'.
|
||||||
final photoFilename = '${DateTime.now().millisecondsSinceEpoch}-${photoUrl.split('/').last.split('?').first.substring(0, 10)}.jpg';
|
final photoFilename = '${DateTime.now().millisecondsSinceEpoch}-${photoUrl.split('/').last.split('?').first.substring(0, 10)}.jpg';
|
||||||
final photoPath =
|
final photoPath =
|
||||||
'${Directory.systemTemp.path}/$photoFilename';
|
'${Directory.systemTemp.path}/$photoFilename';
|
||||||
dio.download(photoUrl, photoPath);
|
await dio.download(photoUrl, photoPath);
|
||||||
return photoPath;
|
return photoPath;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue