alpha0010 / react-native-file-access

Filesystem access for React Native
MIT License
307 stars 19 forks source link

EACCES Permission denied #28

Closed thuynt99 closed 3 years ago

thuynt99 commented 3 years ago
alpha0010 commented 3 years ago

How did you initially save the file? Did you download it with this library?

Nabeel20 commented 3 years ago

Not an expert but did you try adding android:requestLegacyExternalStorage="true" in AndroidManifest.xml in <application> and ask for user permission ?

thuynt99 commented 3 years ago

From Google Play inbox:

We've detected that your app contains the requestLegacyExternalStorage flag in the manifest file of 1 or more of your app bundles or APKs.

Developers with apps on devices running Android 11+ must use Scoped Storage to give users better access control over their device storage. To release your app on Android 11 or newer after May 5th, you must either:

Update your app to use more privacy friendly best practices, such as the Storage Access Framework or Media Store API Update your app to declare the All files access (MANAGE_EXTERNAL_STORAGE) permission in the manifest file, and complete the All files access permission declaration in Play Console from May 5th Remove the All files access permission from your app entirely For apps targeting Android 11, the requestLegacyExternalStorage flag will be ignored. You must use the All files access permission to retain broad access.

Apps requesting access to the All files access permission without a permitted use will be removed from Google Play, and you won't be able to publish updates.

I got this message show i need remove android:requestLegacyExternalStorage="true" in AndroidManifest.xml. So when i readFile image from sd i got error.

alpha0010 commented 3 years ago

As you mention, direct/full filesystem access is being locked down on Android. This means that to access an SD card, the app must either be a file manager app (and so have MANAGE_EXTERNAL_STORAGE permission), or use SAF/Media Store. requestLegacyExternalStorage is there to temporarily enable apps to migrate storage techniques.

All of the Dirs constants in this library, except Dirs.SDCardDir, do not require any special permissions to use. However, they are restricted to only be accessible by this app. This library supports reading storage access framework provided files (on all api calls, if a file is being read from, it can be a SAF link), and writing via Media Store API (see cpExternal()).

If this does not meet your needs, could you further describe your use case?

alpha0010 commented 3 years ago

Assuming resolved.

MaxJadav commented 2 years ago

@alpha0010 Could you share any example how to use SAF/Media Store? I will try to Implement download mp3 file. That file can not access by other source.

alpha0010 commented 2 years ago

@MaxJadav Could you open a new issue regarding expanding the documentation? It will make it easier for me to track.