joltup / rn-fetch-blob

A project committed to making file access and data transfer easier, efficient for React Native developers.
MIT License
2.81k stars 772 forks source link

Ios: Failed to create directory, don’t have permission to save the file #549

Closed DjailinVasu closed 4 years ago

DjailinVasu commented 4 years ago

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.

DjailinVasu commented 4 years ago

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

fabio-jreis commented 4 years ago

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 :)

asphyxiar commented 3 years ago

I have this issue on IOS12 even after using DocumentDir. is there any solution to this?