Rn-fetch-blob: Ios: Failed to create directory, don’t have permission to save the file

Created on 26 Feb 2020  Â·  2Comments  Â·  Source: joltup/rn-fetch-blob

  • rn-fetch-blob: ^0.12.0,
  • react: 16.9.0,
  • react-native: 0.61.5,

I get pdf-file from server and save with fs.writeFile method to fs.dirs.DownloadDir directory.
Result file path is: `${DownloadDir}/${filename}.pdf;`
So, my code is:

RNFetchBlob.fetch(..).then(res => {
      const { fs } = RNFetchBlob;
       let { DownloadDir } = fs.dirs;
      const filePath = `${DownloadDir}/${filename}.pdf `;
      <…>
      fs.writeFile(filePath, res.data, "base64").then(res => {…});
});

This works on ios emulators, but failed when I run the application on a real device with ios 13. By default, I can't catch any error. The process of save file dies quietly.

But if I delete line endings from the received file data as follows:

res.data = res.data.replace(/(\r\n|\n|\r)/gm, "");

I get the following error:

AA88DF1A-06D5-4B70-9BF1-5B0E9A1EE812
CC909F34-5D84-4E44-ADDB-64FE2F1B9150
F823C7B7-FDA8-41B3-B693-EAE7D58191FC

I saw similar access problems in other issues, but could not find a solution.

Most helpful comment

The issue with iOS has been solved by using DocumentDir. all the other folders from fs.dirs are unavailable for writing files in iOS13

All 2 comments

The issue with iOS has been solved by using DocumentDir. all the other folders from fs.dirs are unavailable for writing files in iOS13

The issue with iOS has been solved by using DocumentDir. all the other folders from fs.dirs are unavailable for writing files in iOS13

Thanks :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

msqar picture msqar  Â·  4Comments

hellokunji picture hellokunji  Â·  3Comments

MJXin picture MJXin  Â·  5Comments

n1777 picture n1777  Â·  3Comments

ditkachuk picture ditkachuk  Â·  4Comments