Hi there,
I'm trying to write a file from a base64 string I get from my backend with the following code:
// I also tried adding `file://` at the beginning of the path
const profileImagePath = `${Platform.select({
android: RNFS.DocumentDirectoryPath,
ios: RNFS.MainBundlePath,
})}/${nameOfMyFile}`;
RNFS.writeFile(profileImagePath, imageResponse, 'base64');
but it fails with `ENOENT: no such file or directory, open '/var/containers/Bundle/Application/UUID/NameOfMyApp.app/NameOfMyFile'
What am I doing wrong? 馃槙
Am I not allowed to write in that directory?
P.S. while writing this issue, I tried with const profileImagePath = ${RNFS.DocumentDirectoryPath}/${userResponse.PersonId}.png; instead, and that works.
But how is it different? 馃槄
i got the same problem on ios, working on Android, cannot create new file
did you find a solution ? thks
my code:
const rootPath = (os == "android") ? RNFS.DocumentDirectoryPath : RNFS.MainBundlePath;
writeFile() {
// create a path you want to write to
var path = rootPath + '/test.txt';
// write the file
RNFS.writeFile(path, 'Lorem ipsum dolor sit amet ', 'utf8')
.then((success) => {
console.log('FILE WRITTEN!');
})
.catch((err) => {
console.log(err.message);
});
}
the error :
ENOENT: no such file or directory, open '/var/containers/Bundle/Application/DFFF9E13-1E38-4064-9E61-F6C9A7A8625C/iosTest2.app/test.txt'
Actually, it seems you can't write into MainBundlePath, so I just changed it to use RNFS.DocumentDirectoryPath for both platforms and it works.
This works when I want create a file .mp4?
=========e======= Error: ENOENT: No content provider: /storage/emulated/0/customer-records-27-04-20,06:05:19.xlsx, open '/storage/emulated/0/customer-records-27-04-20,06:05:19.xlsx'
at Object.fn [as writeFile] (NativeModules.js:99)
at Object.writeFile (FS.common.js:424)
at CampaignPerformance._this.handleDownloadFile (index.js:479)
at index.js:457
at index.js:109
at tryCallOne (core.js:37)
at core.js:123
at JSTimers.js:289
at _callTimer (JSTimers.js:146)
at _callImmediatesPass (JSTimers.js:194)
Still having the same issue but no above solution working for this error
=========e======= Error: ENOENT: No content provider: /storage/emulated/0/customer-records-27-04-20,06:05:19.xlsx, open '/storage/emulated/0/customer-records-27-04-20,06:05:19.xlsx'
at Object.fn [as writeFile] (NativeModules.js:99)
at Object.writeFile (FS.common.js:424)
at CampaignPerformance._this.handleDownloadFile (index.js:479)
at index.js:457
at index.js:109
at tryCallOne (core.js:37)
at core.js:123
at JSTimers.js:289
at _callTimer (JSTimers.js:146)
at _callImmediatesPass (JSTimers.js:194)
try to remove : and it will work
Still having the same issue but no above solution working for this error
@Ankit-Reactjs
i have similar eror
a have tried to write file
RNFS.writeFile(folder + `/entities/dd:${addon.config.id}.json`, JSON.stringify(addon.json))
so this dd: cause the error with provider, to check if : cause error try to save file with diferent name , for testing test.xls and check if it works .
Most helpful comment
i have similar eror
a have tried to write file
so this dd: cause the error with provider, to check if
:cause error try to save file with diferent name , for testing test.xls and check if it works .