From 449640699f145ae0c8b121689a2013ba0fb929d5 Mon Sep 17 00:00:00 2001 From: Inex Code Date: Thu, 21 Apr 2022 07:09:41 +0000 Subject: [PATCH] add await for file download --- bin/server.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/server.dart b/bin/server.dart index 71af575..ab88a0c 100644 --- a/bin/server.dart +++ b/bin/server.dart @@ -79,14 +79,14 @@ Future _postOnMastodon(reqJson) async { final photos = attachments.where((attachment) => attachment['type'] == 'photo'); - final photoUrls = photos.map((photo) { + final photoUrls = photos.map((photo) async { final photoUrl = photo['photo']['sizes'].last['url']; // Generate a random filename. // Add the extension '.jpg'. final photoFilename = '${DateTime.now().millisecondsSinceEpoch}-${photoUrl.split('/').last.split('?').first.substring(0, 10)}.jpg'; final photoPath = '${Directory.systemTemp.path}/$photoFilename'; - dio.download(photoUrl, photoPath); + await dio.download(photoUrl, photoPath); return photoPath; });