Closed rochapablo closed 5 years ago
Is the %20 in the filename intentional (Imagem%20JPEG.jpeg)? I think iOS would have a problem with this.
I thought about that and rename the file, but it still cant find the file.
Try using v3 and the fetch()
built into React Native. The React Native FS and React Native Fetch Blob libraries are not supported.
Wait!!!
Just using filename = data.uri.replace('file:', '')
as @andonivianez said here, did work!
The final code:
if (Platform.OS === 'ios') {
filename = data.uri.replace('file:', '')
} else {
filename = data.uri
}
I'm going grab a beer, closing for now!
Thanks @rochapablo for the tip! After getting the URI right with your suggested method, I had to still add the buffer.
yarn add buffer
and importing the buffer to the project
global.Buffer = global.Buffer || require("buffer").Buffer; // buffer needed for file reading
Then everything worked for me.
I still don't know why this is the correct way to read IOS urls in the docs. Took me ages.
based on this for android i did this :
uri.split('raw%3A')[1].replace(/\%2F/gm, '/')
ios:
uri.replace("file://", "")
Hey @rochapablo why did you add Buffer in order to work?
I have tried it with the below way and After that, It's working fine.
let documentURI = doc.uri;
if (Platform.OS === 'ios' ) {
documentURI = decodeURIComponent(documentURI.replace('file://', ''));
}
await RNFetchBlob.fs.readFile(documentURI, 'base64');
I think I found the problem, in my case I had something like this "%20" (seems like an space) in the path I was using and I did something like this uri.replace('file://', '').replaceAll('%20', ' ') and it worked
I think I found the problem, in my case I had something like this "%20" (seems like an space) in the path I was using and I did something like this uri.replace('file://', '').replaceAll('%20', ' ') and it worked
This one worked!!! saved my life.
I think I found the problem, in my case I had something like this "%20" (seems like an space) in the path I was using and I did something like this uri.replace('file://', '').replaceAll('%20', ' ') and it worked
thanks, worked for me
Thanks this solutions work
Following this, i'm trying to get the content file;
Using
react-native-document-picker
, after select the file I do this:I also tried:
But I always get the same error
file not exists
This is the data from
react-native-document-picker
:What could I be missing?