-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[Android] File Creation Error: parent path may not exist #167
Comments
@ksegla , thanks for reporting this issue. I think it's a misleading error message, I will make it more clear. In this case, I think it throws an error due to the destination already has a file as such Android.File.createNewFile() abort this operation. If you intended to overwrite the existing file, try fs.writeFile instead. |
@wkh237 Thanks for the reply. I just tried hard-coding /storage/emulated/0/logs (an existing directory that I used in a previous, unreleased, app of mine) and it worked! So it works with that directory but not with DocumentDirs As DocumentDirs I have To be clear, the file test.txt didn't exist before any of my attempts. Just the directory. It seems indeed though that there is a problem with the error message. When I try to create the DocumentDir (with an mkdir) before the createFile, it warns me that the directory exists already but then, just after, warns that createFile fails because the parent path may not exist. Anyway, the fact that it works with my logs directory is already great for some experiments but it would be much better if I could make it work with the default dirs. Especially, for cross platform smoothness. Do you have any idea what could cause this? I checked your code and the /data/data/APP_PACKAGE/ seems to come from the application context. I will double check android permissions and permissions on the directories. PS: When there is a ( empty) file test.txt already and I use fs.writeFile, I don't have any warning, just nothing written in the file. |
For reference and documentation on this open issue, I think/hope I solved this particular error message issue in this PR: #489 This is related to my own isse #460 "Error normalization (ongoing, tracking)". You can test once my PR is merged and 0.10.9 released, or from my own 0.10.9 repo branch at https://github.com/lll000111/react-native-fetch-blob/tree/0.10.9 I'll close this issue, feel free to reopen if the patch does not help . |
@lll000111 I also got the same problem, how to npm install [email protected]? |
Hi
Thanks for the much needed module. I'm trying to make it work but I'm having
"create file error: failed to create file at path
" + path + "
for its parent path may not exists"path being /data/data/my_app_package/files/test.txt
/storage/emulated/0/data/data does exist and I even manually created the directory my_app_package to which I added directories files and cache.
Code:
const NEW_FILE_PATH = dirs.DocumentDir + '/test.txt';
const fs = RNFetchBlob.fs
fs.createFile(NEW_FILE_PATH, 'foo', 'utf8')
I followed the instructions, added external_storage access permission. Anything I missed?
RN: 0.34.1
RNFB: 0.9.6
Android: 5.0.2 (Samsung S6)
Thanks
The text was updated successfully, but these errors were encountered: