File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -44,6 +44,9 @@ class DownloadService {
4444 Function (InternalError )? onError,
4545 }) async {
4646 String ? externalStorageDirPath;
47+ // fix https://github.com/huynguyennovem/netshare/issues/67:
48+ // file name has space > need to encode the uri
49+ String downloadFileUrl = fileUrl;
4750 if (Platform .isAndroid) {
4851 try {
4952 externalStorageDirPath = await AndroidPathProvider .downloadsPath;
@@ -54,26 +57,27 @@ class DownloadService {
5457 }
5558 } else if (Platform .isIOS) {
5659 externalStorageDirPath = (await getApplicationDocumentsDirectory ()).absolute.path;
60+ downloadFileUrl = Uri .encodeFull (fileUrl);
5761 }
5862 if (null != externalStorageDirPath) {
5963 final savedDir = Directory (externalStorageDirPath);
6064 if (! savedDir.existsSync ()) {
6165 await savedDir.create ();
6266 }
6367 final taskId = await FlutterDownloader .enqueue (
64- url: fileUrl ,
68+ url: downloadFileUrl ,
6569 savedDir: savedDir.path,
6670 saveInPublicStorage: true ,
6771 );
6872 debugPrint ('Download taskId: $taskId ' );
6973
7074 // add to stream
71- final fileName = path.basename (fileUrl );
75+ final fileName = path.basename (downloadFileUrl );
7276 updateDownloadState (
7377 DownloadEntity (
7478 taskId ?? fileName,
7579 fileName,
76- fileUrl ,
80+ downloadFileUrl ,
7781 savedDir.path,
7882 DownloadManner .flutterDownloader,
7983 DownloadState .downloading,
You can’t perform that action at this time.
0 commit comments