Browse Source

generate more normal filenames

master
Inex Code 5 months ago
parent
commit
2d72315584
  1. 5
      bin/server.dart

5
bin/server.dart

@ -81,8 +81,11 @@ Future<void> _postOnMastodon(reqJson) async { @@ -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;
});

Loading…
Cancel
Save