react-native-firestack: filepath.replace is not a function
I got “filepath.replace is not a function” when I try to upload some picture to firebase storage.
`
const firestack = new Firestack();
firestack.storage.setStorageUrl('chatapp-e4bc6.appspot.com');
firestack.storage.uploadFile('photos/1.jpg', source, {
contentType: 'image/jpeg',
contentEncoding: 'base64',
})
.then((res) => console.log('The file has been uploaded'))
.catch(err => console.error('There was an error uploading the file', err))`
Running on Android Emulator.
update: The problem is in “storage.js” line 85:
About this issue
- Original URL
- State: open
- Created 7 years ago
- Reactions: 2
- Comments: 15 (1 by maintainers)
I think I found the solution… If you are using react-native-firebase, you don’t need to create a blob file. Just pass the path of the picture to .put method.
imageRef.put(uri, { contentType: mime });It seems react-native-firebase takes care of all else.Same error here, any suggestions?
Edit:
return imageRef.put(blob._ref, { contentType: mime });Fixed it for me, but files are getting uploaded without file extension, any ideas?
Before I used rn-fetch-blob with ‘firebase’ (the npm package), when I use react-native-firebase, no need this lib (rn-fetch-blob) anymore.
imageRef.put(uri,...like @perrosnk mentioned is a good answer for the issue.@justfede I have a similar issue, but I couldn’t get it solved. You could check the code below.
I get this error. { [TypeError: undefined is not a function (evaluating ‘filePath.replace(‘file://’, ‘’)’)]
Can you please help me?
@perrosnk Thanks I spent whole day for this error But now it works for me
very very thanks