apache / cordova-plugin-file-transfer

Apache Cordova File Transfer Plugin
https://cordova.apache.org/
Apache License 2.0
595 stars 888 forks source link

Upload was not working in API level 32 in Android #356

Open Tejesh-Kumar-tech opened 1 year ago

Tejesh-Kumar-tech commented 1 year ago

image

Getting this error when we are trying to upload a file to server Tried placing android:requestLegacyExternalStorage="true" , but no use

am using Ionic image_2022_12_13T09_11_39_118Z

Please help if any one has solution for this

hydrococcous commented 1 year ago

I have the same problem here. As far as I could find out, it is necessary to set the following access in AndroidManifest.xml:

`

`

However, Google is very restrictive when it comes to this setting: More information here: https://developer.android.com/training/data-storage/manage-all-files#all-files-access-google-play

In my specific case, I download files for editing. After I edited the file with another app, e.g. Word, I no longer have access to it and I get the same error you described above.

Have you found a solution?

Here is my Output from Logcat:

{"code":1,"source":"file:\/\/\/storage\/emulated\/0\/Documents\/xxx\/xxx\/2110--199705\/file.docx","target":"https:\/\/domain.com\/api\/write","body":"{\"_error\":{\"1\":{\"hl\":\"xxx \\\/ ApiService\",\"eMsg\":\"Funktion 'xxxxx' yyyyy.\",\"addInfo\":\"\",\"icon\":\"48\",\"Type\":6,\"errNo\":131045,\"Modul\":\"ApiService\",\"PID\":3404,\"Computer\":\"XXX\"}}}","http_status":400,"exception":"\/storage\/emulated\/0\/Documents\/xxx\/xxx\/2110--199705\/file.docx: open failed: EACCES (Permission denied)"} java.io.FileNotFoundException: /storage/emulated/0/Documents/xxx/xxx/2110--199705/file.docx: open failed: EACCES (Permission denied) at libcore.io.IoBridge.open(IoBridge.java:575) at java.io.FileInputStream.<init>(FileInputStream.java:160) at java.io.FileInputStream.<init>(FileInputStream.java:115) at org.apache.cordova.CordovaResourceApi.openForRead(CordovaResourceApi.java:249) at org.apache.cordova.CordovaResourceApi.openForRead(CordovaResourceApi.java:232) at org.apache.cordova.filetransfer.FileTransfer$1.run(FileTransfer.java:395) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) at java.lang.Thread.run(Thread.java:920) Caused by: android.system.ErrnoException: open failed: EACCES (Permission denied) at libcore.io.Linux.open(Native Method) at libcore.io.ForwardingOs.open(ForwardingOs.java:567) at libcore.io.BlockGuardOs.open(BlockGuardOs.java:273) at libcore.io.ForwardingOs.open(ForwardingOs.java:567) at android.app.ActivityThread$AndroidOs.open(ActivityThread.java:8442) at libcore.io.IoBridge.open(IoBridge.java:561) at java.io.FileInputStream.<init>(FileInputStream.java:160)  at java.io.FileInputStream.<init>(FileInputStream.java:115)  at org.apache.cordova.CordovaResourceApi.openForRead(CordovaResourceApi.java:249)  at org.apache.cordova.CordovaResourceApi.openForRead(CordovaResourceApi.java:232)  at org.apache.cordova.filetransfer.FileTransfer$1.run(FileTransfer.java:395)  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)  at java.lang.Thread.run(Thread.java:920) 

rolinger commented 1 year ago

For anyone still needing a solution, see this post:

https://github.com/apache/cordova-plugin-file-transfer/issues/339#issuecomment-1450747708