generate more normal filenames

This commit is contained in:
Inex Code 2022-04-21 07:08:28 +00:00
parent d455883369
commit 2d72315584
1 changed files with 4 additions and 1 deletions

View File

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