3

we are using react-native-fs for android 11. i have the problem that i can't save Pfd and Excel files on the Downloads folder (/storage/emulated/0/Download) anymore, because we edit the files via other apps and then upload the file again in our app. I know that from Android 11 the storage accesses have changed and it is only possible on the so called scope storage. Is there with react-native-fs or somehow also different (via React Native) to store the files so that also other apps can see the files or you can open them in the file explorer of Android or see them like a shared folder for all apps. There is also the possibility with MANAGE_EXTERNAL_STORAGE but this setting is reserved for certain apps only according to Android.

React native version: 64.2 react-native-fs: 2.18.0 Andriod 11

Thanks in advance

  // /storage/emulated/0/Download/E-Akte_Schadenformular_2020.xlsx
  path = RNFS.DownloadDirectoryPath + '/' + dataBezeichnung + '.' + data.dateityp;



console.log('RNFS.DownloadDirectoryPath');
console.log(path);


  // write the file
  RNFS.writeFile(path, meThis.state.dateiBase64, 'base64').then((success) => {

    console.log('Datei Erfolgreich Runtergeladen!');

    Functions.toast("ERFOLGREICH", "Runterladen erfolgreich \n\nDie Datei:\n" + dataBezeichnung + '.' + data.dateityp+ "\n\nwurde auf Ihrem Gerät erfolgreich gespeichert", 10000);

  }).catch((err) => {

    Functions.toast("WARNUNG", "Runterladen nicht möglich, um die Datei auf Ihrem Gerät zu speichern, müssen Sie die Berechtigung für die eSASSApp aktivieren unter\n\nGeräteeinstellungen -> Apps -> eSASSAPP -> Berechtigungen -> Dateien und Medien -> (Android bis 10 : Zugriff nur auf Mediendateien zulassen) Oder (Ab Andriod 11: Verwaltung aller Dateien zulassen)", 10000);

    console.log(err.message);
  });

Error Message:

ENOENT: open failed: EACCES (Permission denied), open '/storage/emulated/0/Download/E-Akte_Schadenformular_2020.xlsx'

Benq
  • 49
  • 1
  • 3
  • On an Android 11 device every app can create and write files with any extension in Download and Documents folder. I dont know why you can not do that with react native. An app does not need MANAGE_EXTERNAL_STORAGE to do so. The files your app creates are not visible by other apps. Unless that other app uses MANAGE_EXTERNAL_STORAGE or uses SAF. – blackapps Oct 07 '21 at 12:04
  • 1
    I get this error message (ENOENT: open failed: EACCES (Permission denied), open '/storage/emulated/0/Download/E-Akte_Schadenformular_2020.xlsx') when I run the code on Android 11 (Api 30) on Android 10 (Api 29) it works. Do you have an example of how I can do this with react-native-fs? Thanks a lot – Benq Oct 07 '21 at 13:18
  • You did not react to my comment so sorry i can not help you then. – blackapps Oct 07 '21 at 15:33
  • 1
    Hi blackapps, thanks for your answer. As you can see I use the function RNFS.writeFile() which creates a file that my app has created and only my app can see it. So you are right that no one else can open it. But this file I could save before Android 11 with the same function in Downloads folder. Since Android 11 not anymore. How do I get that on Android 11 that I can save the file there? I'm looking for a week and do not get on. I would be very happy about your help. Thanks Translated with www.DeepL.com/Translator (free version) – Benq Oct 08 '21 at 06:51
  • Repeat: `On an Android 11 device every app can create and write files with any extension in Download and Documents folder. I dont know why you can not do that with react native. `. And i do not use react native. – blackapps Oct 08 '21 at 06:59

0 Answers0