fluttercommunity / fluttercommunity/flutter_downloader

File downloaded but the image is corrupted (zero byte)

Open
#360 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Kotlin
Stars
940
Forks
561
Avg merge
1h 18m
Merged PRs (30d)
1

Description

log :
```
D/DownloadWorker(29227): Content-Type = image/jpeg
D/DownloadWorker(29227): Content-Length = 123090
D/DownloadWorker(29227): Charset = null
D/DownloadWorker(29227): Content-Disposition = null
D/DownloadWorker(29227): fileName = close-up-blank-old-concrete-wall_23-2147856094.jpg
D/DownloadWorker(29227): insert description= _display_name=close-up-blank-old-concrete-wall_23-2147856094.jpg datetaken=1603787780862 mime_type=image/jpeg _data=/storage/emulated/0/Android/data/com.example.boilerplate/files/Download/close-up-blank-old-concrete-wall_23-2147856094.jpg title=close-up-blank-old-concrete-wall_23-2147856094.jpg date_added=1603787780862 to MediaStore
D/DownloadWorker(29227): File downloaded
I/WM-WorkerWrapper(29227): Worker result SUCCESS for Work [ id=ad9cdf32-e678-4cf6-8b9d-dcf552e4acb1, tags={ flutter_download_task, vn.hunghd.flutterdownloader.DownloadWorker } ]
```

code :
```
Future _findLocalPath() async {
final directory = GetPlatform.isAndroid
? await getExternalStorageDirectory()
: await getApplicationDocumentsDirectory();
return directory.path;
}

Future init() async {
_appDirPath = (await _findLocalPath()) + Platform.pathSeparator + 'Download';
final savedDir = Directory(_appDirPath);
bool hasExisted = await savedDir.exists();
if (!hasExisted) {
savedDir.create();
}
}

Future downloadFromUrl(String url, {String saveDir, bool showNotification = false, bool openFileFromNotification = true}) async{
return await FlutterDownloader.enqueue(
url: url,
savedDir: saveDir ?? _appDirPath,
showNotification: showNotification, // show download progress in status bar (for Android)
openFileFromNotification: openFileFromNotification, // click on notification to open downloaded file (for Android)
);
}
```

I put `init()` on my splash screen..

Thank you

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.