将图像上载到Reaction Native中的FireBase存储时出错[Firebase 9.6.2] [英] Error uploading image to firebase storage in React Native [ Firebase 9.6.2]
本文介绍了将图像上载到Reaction Native中的FireBase存储时出错[Firebase 9.6.2]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
const uploadPhoto = async() => {
// console.log(image);
// const uploadUri = image;
// let filename = uploadUri.substring(uploadUri.lastIndexOf('/') + 1);
const metadata = {
//path: '../../firebase_image.jpg',
contentType: 'image/jpeg'
};
const photog = `./photo.jpg`;
console.log(photog);
console.log(uploadUri);
const storageRef;
storageRef=ref(storage, 'photogra.jpg');//filename+
uploadBytes(storageRef, photog, metadata).then((snapshot) => {
console.log('Uploaded a blob or file!');
});
}
推荐答案
希望您一切安好!
我从这个令人惊叹的教程中获得了信息,并且对我来说工作得很好 https://www.youtube.com/watch?v=H-yXO46WDak&lc=z22ph5dhssfqufkcxacdp430segloszlmvuqlp1seplw03c010c
尝试此操作:
const ploadImageFirebase=async()=>;{
const nameImage = new Date().toISOString();
const img = await fetch(image);
const bytes = await img.blob();
try {
await uploadBytes(ref_con, bytes);
} catch (error) {
console.log(error);
} finally {
//
}
};
这篇关于将图像上载到Reaction Native中的FireBase存储时出错[Firebase 9.6.2]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文