简体   繁体   中英

Uploading image from React-Native app to Firebase storage

In React-Native app how can i upload an image from user' device to Firebase storage? I'm doing like:

var file = {
   uri: 'file:///Users/...../LONG_PATH/....../Documents/images/name.jpg'
}

var storageRef = this.firebase.storage().ref();
var uploadTask = storageRef.child('images/' + file.name).put(file);

But it throws an error:

Possible Unhandled Promise Rejection (id: 0):

Firebase Storage: Invalid argument in put at index 0: Can't find variable: Blob

I found this, hopefully this helps. Functional React-Native with Firebase storage Example

In this post , software engineer said:

React Native does not support the File and Blob types, so Firebase Storage uploads will not work in this environment. File downloads do work however.

But I found this module wich can transform file to blob types. Maibe can help in your solution

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM