fix(main): file name

This commit is contained in:
ksenia312
2024-02-02 19:16:33 +01:00
parent 8c33c44463
commit 4601abe155
2 changed files with 9 additions and 1 deletions
+1 -1
View File
@@ -399,7 +399,7 @@ class AppService extends ChangeNotifier {
final content = nearbyFile.info; final content = nearbyFile.info;
final downloadsDir = Directory('storage/emulated/0/Download'); final downloadsDir = Directory('storage/emulated/0/Download');
final newFile = await nearbyFile.file.copy( final newFile = await nearbyFile.file.copy(
'${downloadsDir.path}/${content.name}', '${downloadsDir.path}/${DateTime.now().microsecondsSinceEpoch}.${content.extension}',
); );
files.add(newFile); files.add(newFile);
} }
+8
View File
@@ -80,6 +80,14 @@ class NearbyFileInfo {
} }
} }
String get extension {
try {
return name.split('.').last;
} catch (e) {
throw NearbyServiceException('Can\'t get extension from $name');
}
}
@override @override
String toString() { String toString() {
return 'NearbyFileInfo{path: $path}'; return 'NearbyFileInfo{path: $path}';