|
|
|
@ -79,14 +79,14 @@ Future<void> _postOnMastodon(reqJson) async {
@@ -79,14 +79,14 @@ Future<void> _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; |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|