I tried to download pdf files from firebase storage using flutter downloader package. But download always shows failed.I dont know what is the reason.
This is the code I tried. Please suggest some solutions.Thanks in advance.
void _startDownload(String link) async
{
var dir = await getExternalStorageDirectory();
try{
final taskId = await FlutterDownloader.enqueue(
url: link,
savedDir: dir.path,
fileName:"sampe.docx",
showNotification: true, // show download progress in status bar(forAndroid)
openFileFromNotification: true, // click on notification to open downloaded file (for Android)
);
debugPrint(taskId);
// FlutterDownloader.retry(taskId: taskId);
}
catch(e){
print(e);
}
}
This is the error I received .
W/System.err(18012): java.io.FileNotFoundException: /storage/emulated/0/sampe.docx (Permission denied)
W/System.err(18012): at java.io.FileOutputStream.open(Native Method)
W/System.err(18012): at java.io.FileOutputStream.<init>(FileOutputStream.java:221)
W/System.err(18012): at java.io.FileOutputStream.<init>(FileOutputStream.java:140)
W/System.err(18012): at vn.hunghd.flutterdownloader.DownloadWorker.downloadFile(DownloadWorker.java:190)
W/System.err(18012): at vn.hunghd.flutterdownloader.DownloadWorker.doWork(DownloadWorker.java:102)
W/System.err(18012): at androidx.work.Worker$1.run(Worker.java:57)
W/System.err(18012): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
W/System.err(18012): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
W/System.err(18012): at java.lang.Thread.run(Thread.java:760)
I/WorkerWrapper(18012): Worker result SUCCESS for Work [ id=b7676538-a655-454a-89e2-1899f0e078cd, tags={ vn.hunghd.flutterdownloader.DownloadWorker, flutter_download_task } ]