Skip to content
Advertisement

java.io.FileNotFoundException: open failed: EACCES (Permission denied) when uploading csv

I am uploading a file to my php webserver, but however I’m getting the permission denied. It works for mp3 and image extensions. However for .csv, i’ll get that error when i hit upload. I’m new to this and I can’t figure out if its the permission issue on android or the upload doesn’t support uploading of csv. Appreciate any guidance or help. Thanks!

The issue lies with the FileInputStream fileInputStream = new FileInputStream(sourceFile); part where it will hit error and won’t go past there. But if its an image extention or music, it will not show the permission error and successfully uploads.

Android Studio Code

JavaScript

My PHP Webserver Script

JavaScript

Error Logs

JavaScript

Here is the Image of my directory: Android Manifest

JavaScript

Device File Explorer Pointing to the file

Advertisement

Answer

The error you report is generated due to what is called “Scoped storage” of android 11

From the tests I have done this also occurs:
1) Create a folder (from your app) in /storage/emulated/0/Download/Test
2) Create inside a test.csv file from the app
3) Modify the content of the file or overwrite it with the user’s or server’s csv file. via
usb PC, NETWORK or from Android using X-plore, Es-explorer, etc.

You just lost access to that file!


Basically you create your own directory, which did not even exist before and you find yourself not having access to the files contained in it if these are pasted manually or through another app that has access … I think it is an anomaly, I hope so we say.

The solution on Android 11 is to completely review the reading and writing of data with the new system of accessing files residing in external directories or even better is that they back off and stay (at least for directories created by the same developer) as before…hopefully in google common sense

Consult the documentation (I have not understood what I have read…I hope): Storage updates in Android 11

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement