smanikandan14 / ThinDownloadManager

To download files and to avoid using DOWNLOAD_WITHOUT_NOTIFICATION permission if you are using Android's DownloadManager in your apps.
Apache License 2.0
782 stars 185 forks source link

Error 1001: Error in creating destination file #98

Open LitlleEugene opened 7 years ago

LitlleEugene commented 7 years ago

i need save file on this link. Manifest had permissions : INTERNET and WRITE_EXTERNAL STORAGE

ThinDownloadManager downloadManager = new ThinDownloadManager(5); Uri downloadUri = Uri.parse("http://uc.osu.ru/wp-admin/rasp/Rasp.-na-17.03.2017.xls"); Uri destinationUri = Uri.parse( Environment.getDownloadCacheDirectory()+ "Rasp.-na-17.03.2017.xls"); DownloadRequest downloadRequest = new DownloadRequest(downloadUri) .setDestinationURI(destinationUri); downloadManager.add(downloadRequest);

    downloadRequest.setDownloadListener(downloadListener );
smanikandan14 commented 7 years ago

@LitlleEugene What is the actual problem here ?

LitlleEugene commented 7 years ago

@smanikandan14 I can not understand what caused the error, how to fix it and finish uploading the file

LitlleEugene commented 7 years ago

@smanikandan14 When trying to download a file produces an error: "Error in creating destination file"

LitlleEugene commented 7 years ago

@smanikandan14 logs my programs, please help me? 03-20 09:44:32.027 20855-23832/com.vk.eugenerps.webfragment D/ThinDownloadManager: cleanupDestination() deleting /storage/emulated/0/DownloadRasp.-na-17.03.2017.xls 03-20 09:45:05.507 20855-24450/com.vk.eugenerps.webfragment V/ThinDownloadManager: Download initiated for 1 03-20 09:45:05.554 20855-24450/com.vk.eugenerps.webfragment V/ThinDownloadManager: Response code obtained for downloaded Id 1 : httpResponse Code 200 03-20 09:45:05.555 20855-24450/com.vk.eugenerps.webfragment D/ThinDownloadManager: cleanupDestination() deleting /storage/emulated/0/DownloadRasp.-na-17.03.2017.xls 03-20 09:45:05.557 20855-24450/com.vk.eugenerps.webfragment W/System.err: java.io.IOException: open failed: EACCES (Permission denied) 03-20 09:45:05.558 20855-24450/com.vk.eugenerps.webfragment W/System.err: at java.io.File.createNewFile(File.java:939) 03-20 09:45:05.558 20855-24450/com.vk.eugenerps.webfragment W/System.err: at com.thin.downloadmanager.DownloadDispatcher.transferData(DownloadDispatcher.java:218) 03-20 09:45:05.558 20855-24450/com.vk.eugenerps.webfragment W/System.err: at com.thin.downloadmanager.DownloadDispatcher.executeDownload(DownloadDispatcher.java:147) 03-20 09:45:05.558 20855-24450/com.vk.eugenerps.webfragment W/System.err: at com.thin.downloadmanager.DownloadDispatcher.run(DownloadDispatcher.java:83) 03-20 09:45:05.558 20855-24450/com.vk.eugenerps.webfragment W/System.err: Caused by: android.system.ErrnoException: open failed: EACCES (Permission denied) 03-20 09:45:05.558 20855-24450/com.vk.eugenerps.webfragment W/System.err: at libcore.io.Posix.open(Native Method) 03-20 09:45:05.558 20855-24450/com.vk.eugenerps.webfragment W/System.err: at libcore.io.BlockGuardOs.open(BlockGuardOs.java:186) 03-20 09:45:05.558 20855-24450/com.vk.eugenerps.webfragment W/System.err: at java.io.File.createNewFile(File.java:932) 03-20 09:45:05.558 20855-24450/com.vk.eugenerps.webfragment W/System.err: ... 3 more 03-20 09:45:05.558 20855-24450/com.vk.eugenerps.webfragment D/ThinDownloadManager: cleanupDestination() deleting /storage/emulated/0/DownloadRasp.-na-17.03.2017.xls

smanikandan14 commented 7 years ago

What is the OS version. ? Could be that you have not given granted permission to write to external SD card. Pls check. http://stackoverflow.com/questions/33139754/android-6-0-marshmallow-cannot-write-to-sd-card

Pirokar commented 7 years ago

Didn't work. If we have a lof of files to download, some files still fire "Error in creating destination file". This files can be downloaded successfully with next start. But how to download all now...

lokalkart commented 4 years ago

@smanikandan14 I am also facing this issue . at com.thin.downloadmanager.DownloadDispatcher.executeDownload(DownloadDispatcher.java:138) and application crashes. and it usually happens when the file size is big or in some specific file types like epub etc. No issue related to permission because some are being downloaded successfully.