0

Unsupported path storage/emulated/0/test

Android APIv29 FileNotFoundException EACCES (Permission denied)

https://github.com/joltup/rn-fetch-blob/issues/508

hello there,

In my application when user click on button that time an API call create a csv string and download it to directory

hear is my code working with emulator (android 8) and same code not working with my mobile (android 10)

           const pathToWrite = `${RNFetchBlob.fs.dirs.DownloadDir}/file.csv`;
          
           const csvString = data
            .map((item) => {
              return `${item.map((d) => d)}\n`;
            })
            .join('');

          console.log(csvString);
          RNFetchBlob.fs.writeFile(pathToWrite, csvString, 'utf8').then(() => {
            RNFetchBlob.android.addCompleteDownload({
              title: 'ebol.csv',
              description: 'Download complete',
              mime: 'application/scv',
              path: pathToWrite,
              showNotification: true,
            });

            console.log(`wrote file ${pathToWrite}`);
           
          });


i tried with static path

 const pathToWrite =
        'file:///storage/emulated/0/Android/data/<package.name>/files/file.csv';

but still get error :

Possible Unhandled Promise Rejection (id: 2): Error: Failed to create parent directory of 'file:///storage/emulated/0/Android/data/<package.name>/files/file.csv' promiseMethodWrapper@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:2242:45 writeFile@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:215561:42

Mitesh K
  • 694
  • 1
  • 11
  • 24

1 Answers1

0

After reading many blogs I found that the error happens mostly using "DownloadDir" but not with others. As a needed to place my download files in "DownloadDir", I tried adding a subfolder and it worked for me with RN 0.63.3 testing in android version <= 12.

path: `${RNFetchBlob.fs.dirs.DownloadDir}/anySubFolderName`