fluttercommunity / fluttercommunity/flutter_downloader
Saving to private storage and being thrown `... not setting 'saveInPublicStorage' to 'true'`
- Dominant language
- Kotlin
- Stars
- 940
- Forks
- 561
- Avg merge
- 1h 18m
- Merged PRs (30d)
- 1
Description
**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
```dart
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
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.