将图像从 React-Native 应用程序上传到 Firebase 存储
Uploading image from React-Native app to Firebase storage
在 React-Native 应用程序中,我如何将图像从用户设备上传到 Firebase 存储?我这样做:
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);
但是它抛出一个错误:
Possible Unhandled Promise Rejection (id: 0):
Firebase Storage:
Invalid argument in put
at index 0: Can't find variable: Blob
在此post中,软件工程师说:
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.
但我发现这个 module 可以将文件转换为 blob 类型。 Maibe 可以帮助您解决问题
我找到了这个,希望对您有所帮助。 Functional React-Native with Firebase storage Example
在 React-Native 应用程序中,我如何将图像从用户设备上传到 Firebase 存储?我这样做:
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);
但是它抛出一个错误:
Possible Unhandled Promise Rejection (id: 0):
Firebase Storage: Invalid argument in
put
at index 0: Can't find variable: Blob
在此post中,软件工程师说:
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.
但我发现这个 module 可以将文件转换为 blob 类型。 Maibe 可以帮助您解决问题
我找到了这个,希望对您有所帮助。 Functional React-Native with Firebase storage Example