flutter_downloader icon indicating copy to clipboard operation
flutter_downloader copied to clipboard

Saving to private storage and being thrown `... not setting 'saveInPublicStorage' to 'true'`

Open deimantasa opened this issue 2 years ago • 5 comments

Describe the bug Only first time executes download process correctly and saves to internal app storage directory well. Any other time it will fail with It looks like you are trying to save file in public storage but not setting 'saveInPublicStorage' to 'true' thrown even if saving happens not in public storage. However, after checking file explorer, file does exists in the directory. Thus it seems file is downloaded but process fails.

Some logs below.

Code being used

final downloadDirPath = (await getApplicationSupportDirectory()).path;
...
final taskId = await FlutterDownloader.enqueue(
      url: url,
      savedDir: downloadDirPath,
      showNotification: false,
      openFileFromNotification: false,
      saveInPublicStorage: false,
    );

Error received in the very end of download (file is downloaded, but it fails via worker)

D/DownloadWorker( 8746): Content-Type = application/octet-stream
D/DownloadWorker( 8746): Content-Length = -1
D/DownloadWorker( 8746): Charset = null
D/DownloadWorker( 8746): Content-Disposition = null
D/DownloadWorker( 8746): fileName = 9c6fe69e1e37e2a2de5c2ef2a3b43543-1676121956322-688080294.jpg
E/DownloadWorker( 8746): It looks like you are trying to save file in public storage but not setting 'saveInPublicStorage' to 'true'

And task itself:
[
9cc94ee1-7a46-413f-b412-cca6610a9d01, //task ID
 4, // status
 -1 // progress
 ]

What's weird is that after restarting app, once again, first time download will work. But if it will be triggered any other time - it will fail with above reasoning. Tried in both - emulator and physical device - consistent behaviour. Also, sometimes, if I delete the file directory to download - download will work again and process won't fail. However any other time it will start failing.

When saving to public storage - it does work all the time well.

Flutter 3.7.2
..
flutter_downloader: ^1.10.1+2

deimantasa avatar Feb 12 '23 01:02 deimantasa

Hello. Is there any update on this? I'm facing the same problem. Thanks.

SvehlaJan avatar May 29 '23 17:05 SvehlaJan

i got this error too, in my case, just add change saveInPublicStorage to true

alvinraa avatar Oct 11 '23 10:10 alvinraa

But after setting saveInPublicStoroage: true I am getting following error :

E/WM-WorkerWrapper( 6535): java.util.concurrent.ExecutionException: android.database.sqlite.SQLiteException: no such column: save_in_public_storage (code 1 SQLITE_ERROR[1]):

Flutter : 3.7.8

Flutter Downloader: 1.10.1

dhavalshah007 avatar Oct 28 '23 22:10 dhavalshah007

It looks like you are trying to save the file in public storage but not setting 'saveInPublicStorage' to 'true' although it is set to true and running fine on android 13 devices but facing an error when running on Android 9 please answer thanks

WajahtAli avatar Feb 29 '24 13:02 WajahtAli

Well, yes, I believe it's a bug. However, right now the possible solution can be just to make the value of saveInPublicStorage: true in the FlutterDownloader.enqueue function.

SpaceBuckett avatar Apr 16 '24 14:04 SpaceBuckett