@@ -46,7 +46,7 @@ class DownloadService {
4646 String ? externalStorageDirPath;
4747 // fix https://github.com/huynguyennovem/netshare/issues/67:
4848 // file name has space > need to encode the uri
49- String downloadFileUrl = fileUrl;
49+ String encodedFileUrl = Uri . encodeFull ( fileUrl) ;
5050 if (Platform .isAndroid) {
5151 try {
5252 externalStorageDirPath = await AndroidPathProvider .downloadsPath;
@@ -57,27 +57,28 @@ class DownloadService {
5757 }
5858 } else if (Platform .isIOS) {
5959 externalStorageDirPath = (await getApplicationDocumentsDirectory ()).absolute.path;
60- downloadFileUrl = Uri .encodeFull (fileUrl);
6160 }
6261 if (null != externalStorageDirPath) {
6362 final savedDir = Directory (externalStorageDirPath);
6463 if (! savedDir.existsSync ()) {
6564 await savedDir.create ();
6665 }
66+ final encodedFileName = path.basename (encodedFileUrl);
67+ final decodedFileName = Uri .decodeFull (encodedFileName);
68+ // use raw file name for beautiful name only (without encoded name)
6769 final taskId = await FlutterDownloader .enqueue (
68- url: downloadFileUrl,
70+ url: encodedFileUrl,
71+ fileName: decodedFileName,
6972 savedDir: savedDir.path,
7073 saveInPublicStorage: true ,
7174 );
72- debugPrint ('Download taskId: $taskId ' );
7375
7476 // add to stream
75- final fileName = path.basename (downloadFileUrl);
7677 updateDownloadState (
7778 DownloadEntity (
78- taskId ?? fileName ,
79- fileName ,
80- downloadFileUrl ,
79+ taskId ?? decodedFileName ,
80+ decodedFileName ,
81+ encodedFileUrl ,
8182 savedDir.path,
8283 DownloadManner .flutterDownloader,
8384 DownloadState .downloading,
0 commit comments