0

i'm trying to download .pdf from a API, but every time the download fails, i already have all the permissions set. I think that the downloader didn't find the folder to save the file, or is looking for the file in the folder. Anyway here is the error messageit outputs: I deleted the api just for security's sake and i also printed the path that is passed to the flutter downloader enqueue Any help would be apreciated.

Restarted application in 6.399ms.
I/OpenGLRenderer( 9052): Initialized EGL, version 1.4
D/OpenGLRenderer( 9052): Swap behavior 1
W/Adreno-EGL( 9052): <qeglDrvAPI_eglGetConfigAttrib:612>: EGL_BAD_ATTRIBUTE
W/Adreno-EGL( 9052): <qeglDrvAPI_eglGetConfigAttrib:612>: EGL_BAD_ATTRIBUTE
W/Adreno-EGL( 9052): <qeglDrvAPI_eglGetConfigAttrib:612>: EGL_BAD_ATTRIBUTE
E/BpSurfaceComposerClient( 9052): Failed to transact (-1)
E/BpSurfaceComposerClient( 9052): Failed to transact (-1)
I/flutter ( 9052): Path: /storage/emulated/0/Android/data/com.example.flutter_consulta_de_multas/files
D/ConnectivityManager( 9052): requestNetwork; CallingUid : 10121, CallingPid : 9052
D/DownloadWorker( 9052): DownloadWorker{url=https://sgmt.lrl.com.br/painel/gerencia-transportes/infracoes/guia-pagamento-pdf/OEX7535/TE03215671/5746,filename=boleto_OEX7535_19/02/2022.pdf,savedDir=/storage/emulated/0/Android/data/com.example.flutter_consulta_de_multas/files,header=,isResume=false,status=1
D/DownloadWorker( 9052): Update notification: {notificationId: 15, title: boleto_OEX7535_19/02/2022.pdf, status: 2, progress: 0}
D/DownloadWorker( 9052): Open connection to ****
D/DownloadWorker( 9052): Content-Type = application/pdf
D/DownloadWorker( 9052): Content-Length = 1430906
D/DownloadWorker( 9052): Charset = null
D/DownloadWorker( 9052): fileName = boleto_OEX7535_19/02/2022.pdf
W/System.err( 9052): java.io.IOException: No such file or directory
W/System.err( 9052):    at java.io.UnixFileSystem.createFileExclusively0(Native Method)
W/System.err( 9052):    at java.io.UnixFileSystem.createFileExclusively(UnixFileSystem.java:281)
W/System.err( 9052):    at java.io.File.createNewFile(File.java:1000)
W/System.err( 9052):    at vn.hunghd.flutterdownloader.DownloadWorker.createFileInAppSpecificDir(DownloadWorker.java:481)
W/System.err( 9052):    at vn.hunghd.flutterdownloader.DownloadWorker.downloadFile(DownloadWorker.java:384)
W/System.err( 9052):    at vn.hunghd.flutterdownloader.DownloadWorker.doWork(DownloadWorker.java:222)
W/System.err( 9052):    at androidx.work.Worker$1.run(Worker.java:86)
W/System.err( 9052):    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
W/System.err( 9052):    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
W/System.err( 9052):    at java.lang.Thread.run(Thread.java:764)
E/DownloadWorker( 9052): Create a file using java.io API failed
D/DownloadWorker( 9052): Update notification: {notificationId: 15, title: boleto_OEX7535_19/02/2022.pdf, status: 4, progress: -1}
W/System.err( 9052): java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.io.File.getPath()' on a null object reference
W/System.err( 9052):    at vn.hunghd.flutterdownloader.DownloadWorker.downloadFile(DownloadWorker.java:385)
W/System.err( 9052):    at vn.hunghd.flutterdownloader.DownloadWorker.doWork(DownloadWorker.java:222)
W/System.err( 9052):    at androidx.work.Worker$1.run(Worker.java:86)
W/System.err( 9052):    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
W/System.err( 9052):    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
W/System.err( 9052):    at java.lang.Thread.run(Thread.java:764)
I/WM-WorkerWrapper( 9052): Worker result FAILURE for Work [ id=a7b1db56-da5d-48aa-add5-5aa4b08156be, tags={ flutter_download_task, vn.hunghd.flutterdownloader.DownloadWorker } ]
D/ConnectivityManager( 9052): unregisterNetworkCallback; CallingUid : 10121, CallingPid : 9052
  • Which package/lib you use to download the pdf, please share the screen that will give you the proper solution. – amirul Apr 01 '22 at 14:39
  • 1
    The filename has `/` in it: `boleto_OEX7535_19/02/2022.pdf` so Java is probably trying to create the file in the `boleto_OEX7535_19/02/` subfolder, but that folder doesn't exist. Either change the filename to remove the '/' character, or pre-create the sub folder. It looks like you have control over the filename, so change it to: `boleto_OEX7535_19-02-2022.pdf` or equivalent. – Richard Heap Apr 01 '22 at 14:41

1 Answers1

1

It's was what Richard Heap said Thanks a lot!!!

The filename has / in it: boleto_OEX7535_19/02/2022.pdf so Java is probably trying to create the file in the boleto_OEX7535_19/02/ subfolder, but that folder doesn't exist. Either change the filename to remove the '/' character, or pre-create the sub folder. It looks like you have control over the filename, so change it to: boleto_OEX7535_19-02-2022.pdf or equivalent.