I'm downloading a file from a server and saving it to the downloads directory on Android with the name test.bin. On a File Manager app, I can see the file was successfully saved to the directory. Also, when using the File System API to check if the file exists with
RNFetchBlob.fs.exists('storage/emulated/0/Download/test.bin').then(exist => console.log(`file${exist ? '' : ' not'} exists`));, it returns that the file indeed exists.
The problem is when trying to make a request to send this file to another place with a multipart/form, like:
RNFetchBlob.fetch('POST', SERVER_URL, {
'Content-Type': 'multipart/form-data'
}, [
{
name: 'name',
data: 'test'
},
{
name: 'filename',
data: 'tmp/test.bin'
},
{
name: 'filedata',
type: 'application/macbinary',
data: RNFetchBlob.wrap(storage/emulated/0/Download/test.bin)
}
])
.then(res => {
console.log('response => ', res);
})
.catch(e => console.log('ERROR => ', e));
I got an error on the response with a message: Failed to open target file, No such file or directory.
react-native: 0.51.0
react-native-fetch-blob: ^0.10.8
Did you fix it?