generate more normal filenames

This commit is contained in:
Inex Code 2022-04-21 07:08:28 +00:00
parent d455883369
commit 2d72315584

View file

@ -81,8 +81,11 @@ Future<void> _postOnMastodon(reqJson) async {
final photoUrls = photos.map((photo) { final photoUrls = photos.map((photo) {
final photoUrl = photo['photo']['sizes'].last['url']; 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 = final photoPath =
'${Directory.systemTemp.path}/${photoUrl.split('/').last.split('?').first}'; '${Directory.systemTemp.path}/$photoFilename';
dio.download(photoUrl, photoPath); dio.download(photoUrl, photoPath);
return photoPath; return photoPath;
}); });