我有多个存储在数组中的图像(存储在数组中的图像路径)。然后我使用 for 循环上传每张图片,但只上传最后一张图片。我使用 react native fetch blob 和 firebase
for(var i = 0; i < this.state.imagesUri;i++){
Blob.build(RNFetchBlob.wrap(this.state.imagesUri[i].path),{ type : 'image/jpeg' })
.then((blob) => firebase.storage()
.ref("userPhoto").child("image"+i)
.put(blob, { contentType : 'image/png' }).then(()=>{
var storage = firebase.storage().ref("userPhoto/").child("image"+i);
storage.getDownloadURL().then((url)=>{
var url = url;
});
})
);
}Run Code Online (Sandbox Code Playgroud)
javascript react-native react-native-android firebase-storage