Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

saveDir didn't work #525

Closed
Jayshanx opened this issue Sep 9, 2021 · 11 comments
Closed

saveDir didn't work #525

Jayshanx opened this issue Sep 9, 2021 · 11 comments

Comments

@Jayshanx
Copy link

Jayshanx commented Sep 9, 2021

when i set savedDir=/storage/emulated/0/Android/data/vn.hunghd.example/files
but files save to /storage/emulated/0/Download/Android-Programming-Cookbook.pdf

  • compileSdkVersion: 30
  • android version: 11
  • flutter_downloader: 1.7.0
  • flutter version: 2.5.0

my code

  Future<String?> _findLocalPath() async {
    var externalStorageDirPath;
    if (Platform.isAndroid) {
      try {
        // externalStorageDirPath = await AndroidPathProvider.downloadsPath;
        externalStorageDirPath = (await getExternalStorageDirectory())?.path;  //<-----------here
      } catch (e) {
        final directory = await getExternalStorageDirectory();
        externalStorageDirPath = directory?.path;
      }
    } else if (Platform.isIOS) {
      externalStorageDirPath = (await getApplicationDocumentsDirectory()).absolute.path;
    }
    return externalStorageDirPath;
  }

logs

[+5686 ms] W/WM-WorkSpec(22928): Backoff delay duration less than minimum value
[  +35 ms] D/DownloadWorker(22928): DownloadWorker{url=http://enos.itcollege.ee/~jpoial/allalaadimised/reading/Android-Programming-Cookbook.pdf,filename=null,savedDir=/storage/emulated/0/Android/data/vn.hunghd.example/files,header={"auth": "test_for_sql_encoding"},isResume=false
[   +1 ms] D/DownloadWorker(22928): Update notification: {notificationId: 5, title: http://enos.itcollege.ee/~jpoial/allalaadimised/reading/Android-Programming-Cookbook.pdf, status: 2, progress: 0}
[  +10 ms] D/DownloadWorker(22928): Open connection to http://enos.itcollege.ee/~jpoial/allalaadimised/reading/Android-Programming-Cookbook.pdf
[        ] D/DownloadWorker(22928): Headers = {"auth": "test_for_sql_encoding"}
[   +2 ms] I/flutter (22928): Background Isolate Callback: task (384f753e-2958-4526-9fbc-9d2b12641b9d) is in status (DownloadTaskStatus(2)) and process (0)
[   +5 ms] I/flutter (22928): UI Isolate Callback: [384f753e-2958-4526-9fbc-9d2b12641b9d, DownloadTaskStatus(2), 0]
[ +690 ms] D/DownloadWorker(22928): Response with redirection code
[        ] D/DownloadWorker(22928): Location = https://enos.itcollege.ee/~jpoial/allalaadimised/reading/Android-Programming-Cookbook.pdf
[        ] D/DownloadWorker(22928): New url: https://enos.itcollege.ee/~jpoial/allalaadimised/reading/Android-Programming-Cookbook.pdf
[        ] D/DownloadWorker(22928): Open connection to https://enos.itcollege.ee/~jpoial/allalaadimised/reading/Android-Programming-Cookbook.pdf
[   +1 ms] D/DownloadWorker(22928): Headers = {"auth": "test_for_sql_encoding"}
[+1332 ms] D/DownloadWorker(22928): Content-Type = application/pdf
[        ] D/DownloadWorker(22928): Content-Length = 8620159
[        ] D/DownloadWorker(22928): Charset = null
[        ] D/DownloadWorker(22928): Content-Disposition = null
[        ] D/DownloadWorker(22928): fileName = Android-Programming-Cookbook.pdf
[ +645 ms] D/DownloadWorker(22928): Update notification: {notificationId: 5, title: Android-Programming-Cookbook.pdf, status: 2, progress: 1}
[   +3 ms] I/flutter (22928): Background Isolate Callback: task (384f753e-2958-4526-9fbc-9d2b12641b9d) is in status (DownloadTaskStatus(2)) and process (1)
[        ] I/flutter (22928): UI Isolate Callback: [384f753e-2958-4526-9fbc-9d2b12641b9d, DownloadTaskStatus(2), 1]
[+1891 ms] D/DownloadWorker(22928): Update notification: {notificationId: 5, title: Android-Programming-Cookbook.pdf, status: ...
...
...
...
[        ] I/flutter (22928): UI Isolate Callback: [384f753e-2958-4526-9fbc-9d2b12641b9d, DownloadTaskStatus(2), 100]
[  +18 ms] D/DownloadWorker(22928): File downloaded (/storage/emulated/0/Download/Android-Programming-Cookbook.pdf)
[   +3 ms] D/DownloadWorker(22928): Setting an intent to open the file /storage/emulated/0/Download/Android-Programming-Cookbook.pdf               //<<<<<<<<<<------------------------here


[        ] I/flutter (22928): Background Isolate Callback: task (384f753e-2958-4526-9fbc-9d2b12641b9d) is in status (DownloadTaskStatus(3)) and process (100)
[   +1 ms] D/DownloadWorker(22928): Update too frequently!!!!, but it is the final update, we should sleep a second to ensure the update call can be processed
[   +5 ms] I/flutter (22928): UI Isolate Callback: [384f753e-2958-4526-9fbc-9d2b12641b9d, DownloadTaskStatus(3), 100]
[  +10 ms] D/MediaScannerConnection(22928): Scanned /storage/emulated/0/Download/Android-Programming-Cookbook.pdf to content://media/external_primary/file/319376
[        ] D/DownloadWorker(22928): MediaStore updated (content://media/external_primary/file/319376)
[ +985 ms] D/DownloadWorker(22928): Update notification: {notificationId: 5, title: Android-Programming-Cookbook.pdf, status: 3, progress: 100}
[   +8 ms] D/DownloadWorker(22928): File downloaded
[   +5 ms] I/WM-WorkerWrapper(22928): Worker result SUCCESS for Work [ id=384f753e-2958-4526-9fbc-9d2b12641b9d, tags={ flutter_download_task, vn.hunghd.flutterdownloader.DownloadWorker } ]

@cyanlink
Copy link

cyanlink commented Sep 9, 2021

+1, can reproduce here.

@Jayshanx
Copy link
Author

here the code seems to be the problem

@Jayshanx Jayshanx changed the title saveDir didn't work in flutter 2.5.0 saveDir didn't work Sep 10, 2021
@tijanirf
Copy link

Also happened to me on:

  • android version: 9
  • flutter_downloader: 1.6.0
  • flutter version: 2.5.0

But, it was previously successful:

  • android version: 9
  • flutter_downloader: 1.6.0
  • flutter version: 2.2.1

Maybe the culprit is flutter 2.5.0

@ronny-sugianto
Copy link

ronny-sugianto commented Sep 10, 2021

Also happened to me on:

  • android version: 9
  • flutter_downloader: 1.6.0
  • flutter version: 2.5.0

But, it was previously successful:

  • android version: 9
  • flutter_downloader: 1.6.0
  • flutter version: 2.2.1

Maybe the culprit is flutter 2.5.0

I also experienced the same thing,
but i'm using android version : 11 (api 30)

@Jayshanx
Copy link
Author

Also happened to me on:

  • android version: 9
  • flutter_downloader: 1.6.0
  • flutter version: 2.5.0

But, it was previously successful:

  • android version: 9
  • flutter_downloader: 1.6.0
  • flutter version: 2.2.1

Maybe the culprit is flutter 2.5.0

Also happened to me on:

  • android version: 9
  • flutter_downloader: 1.6.0
  • flutter version: 2.5.0

But, it was previously successful:

  • android version: 9
  • flutter_downloader: 1.6.0
  • flutter version: 2.2.1

Maybe the culprit is flutter 2.5.0

flutter 2.5.0 is not culprit , you can see pr #526 (comment)

@Jayshanx
Copy link
Author

Also happened to me on:

  • android version: 9
  • flutter_downloader: 1.6.0
  • flutter version: 2.5.0

But, it was previously successful:

  • android version: 9
  • flutter_downloader: 1.6.0
  • flutter version: 2.2.1

Maybe the culprit is flutter 2.5.0

I also experienced the same thing,
but i'm android version : 11 (api 30)

The problem has been solved, you can use #526 (comment)

@tijanirf
Copy link

#526 (comment)

I just realized it was already mentioned before my comment.

Checked the PR, hope it merged soon.

@hnvn
Copy link
Member

hnvn commented Sep 11, 2021

There's change on android storage management from Android 11. please upgrade to v1.7.0

@hnvn hnvn closed this as completed Sep 11, 2021
@tijanirf
Copy link

Actually, we tried first on flutter 2.5 & flutter_downloader v1.7.0 and the error happened. Then we tried downgrading as I mentioned above in my comment. We end up rollback our app to flutter 2.2.1 and flutter_downloader v1.6.0 to make it works.

I'll try to debug deeper and let you know about my findings on monday 🤞

@tijanirf
Copy link

Actually, we tried first on flutter 2.5 & flutter_downloader v1.7.0 and the error happened. Then we tried downgrading as I mentioned above in my comment. We end up rollback our app to flutter 2.2.1 and flutter_downloader v1.6.0 to make it works.

I'll try to debug deeper and let you know about my findings on monday 🤞

There's change on android storage management from Android 11. please upgrade to v1.7.0

I just tested on these specs and still got the same issue as mentioned above:

  • android version: 9
  • flutter_downloader: 1.7.0
  • flutter version: 2.5.0
Logs
D/DownloadWorker( 5067): DownloadWorker{url=https://storage.googleapis.com/vx_dev_tasks/tasks/710/INV2021015974 (1).pdf,filename=null,savedDir=/storage/emulated/0/Android/data/com.sunterra.vx.dev/files/Downloads,header=,isResume=false
D/DownloadWorker( 5067): Open connection to https://storage.googleapis.com/vx_dev_tasks/tasks/710/INV2021015974 (1).pdf
D/DownloadWorker( 5067): Content-Type = application/pdf
D/DownloadWorker( 5067): Content-Length = 85763
D/DownloadWorker( 5067): Charset = null
D/DownloadWorker( 5067): Content-Disposition = null
D/DownloadWorker( 5067): fileName = INV2021015974 (1).pdf
D/DownloadWorker( 5067): File downloaded (/storage/emulated/0/Download/INV2021015974 (1).pdf)
D/DownloadWorker( 5067): File downloaded
I/WM-WorkerWrapper( 5067): Worker result SUCCESS for Work [ id=e40f444b-ab20-49b9-b58d-12b77fe94c57, tags={ flutter_download_task, vn.hunghd.flutterdownloader.DownloadWorker } ]
D/DownloadWorker( 5067): MediaStore updated (content://media/external/file/696232)
I/flutter ( 5067): Background Isolate Callback: task (e40f444b-ab20-49b9-b58d-12b77fe94c57) is in status (DownloadTaskStatus(2)) and process (0)
I/flutter ( 5067): Background Isolate Callback: task (e40f444b-ab20-49b9-b58d-12b77fe94c57) is in status (DownloadTaskStatus(2)) and process (2)
I/flutter ( 5067): Background Isolate Callback: task (e40f444b-ab20-49b9-b58d-12b77fe94c57) is in status (DownloadTaskStatus(2)) and process (8)
I/flutter ( 5067): Background Isolate Callback: task (e40f444b-ab20-49b9-b58d-12b77fe94c57) is in status (DownloadTaskStatus(2)) and process (14)
I/flutter ( 5067): Background Isolate Callback: task (e40f444b-ab20-49b9-b58d-12b77fe94c57) is in status (DownloadTaskStatus(2)) and process (21)
I/flutter ( 5067): Background Isolate Callback: task (e40f444b-ab20-49b9-b58d-12b77fe94c57) is in status (DownloadTaskStatus(2)) and process (27)
I/flutter ( 5067): Background Isolate Callback: task (e40f444b-ab20-49b9-b58d-12b77fe94c57) is in status (DownloadTaskStatus(2)) and process (34)
I/flutter ( 5067): Background Isolate Callback: task (e40f444b-ab20-49b9-b58d-12b77fe94c57) is in status (DownloadTaskStatus(2)) and process (41)
I/flutter ( 5067): Background Isolate Callback: task (e40f444b-ab20-49b9-b58d-12b77fe94c57) is in status (DownloadTaskStatus(2)) and process (47)
I/flutter ( 5067): Background Isolate Callback: task (e40f444b-ab20-49b9-b58d-12b77fe94c57) is in status (DownloadTaskStatus(2)) and process (54)
I/flutter ( 5067): Background Isolate Callback: task (e40f444b-ab20-49b9-b58d-12b77fe94c57) is in status (DownloadTaskStatus(2)) and process (60)
I/flutter ( 5067): Background Isolate Callback: task (e40f444b-ab20-49b9-b58d-12b77fe94c57) is in status (DownloadTaskStatus(2)) and process (66)
I/flutter ( 5067): Background Isolate Callback: task (e40f444b-ab20-49b9-b58d-12b77fe94c57) is in status (DownloadTaskStatus(2)) and process (73)
I/flutter ( 5067): Background Isolate Callback: task (e40f444b-ab20-49b9-b58d-12b77fe94c57) is in status (DownloadTaskStatus(2)) and process (79)
I/flutter ( 5067): Background Isolate Callback: task (e40f444b-ab20-49b9-b58d-12b77fe94c57) is in status (DownloadTaskStatus(2)) and process (86)
I/flutter ( 5067): Background Isolate Callback: task (e40f444b-ab20-49b9-b58d-12b77fe94c57) is in status (DownloadTaskStatus(2)) and process (92)
I/flutter ( 5067): Background Isolate Callback: task (e40f444b-ab20-49b9-b58d-12b77fe94c57) is in status (DownloadTaskStatus(2)) and process (98)
I/flutter ( 5067): Background Isolate Callback: task (e40f444b-ab20-49b9-b58d-12b77fe94c57) is in status (DownloadTaskStatus(2)) and process (100)
I/flutter ( 5067): Background Isolate Callback: task (e40f444b-ab20-49b9-b58d-12b77fe94c57) is in status (DownloadTaskStatus(3)) and process (100)

Even though it's written DownloadWorker{url=https://storage.googleapis.com/vx_dev_tasks/tasks/710/INV2021015974 (1).pdf,filename=null,savedDir=/storage/emulated/0/Android/data/com.sunterra.vx.dev/files/Downloads,header=,isResume=false, the file is not exist on the savedDir. The file is downloaded to /storage/emulated/0/Download/INV2021015974 (1).pdf

I'm not using android 11, so upgrading to v1.7.0 won't fix the problem.

@hnvn
Copy link
Member

hnvn commented Oct 9, 2021

Please upgrade to v1.7.1. For more detail, please have a look at this comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants