我正在尝试使用React-Native-Fetch-Blob在Firebase.Storage中存储图像,我终于将一些东西存储到存储中,但是存储中的文件现在是完全没有意义的/压缩的数据,我不能真正地使用它们。
如何将blob转换回BASE64或图像,以便在应用程序中使用该图像
`
upLoadImage(image, mime = 'application/octet-stream') {
const imageRef = firebase.storage().ref('images').child('image_001')
let uploadBlob = null
console.log('phase 2');
Blob.build(image, {
type: `${mime};BASE64`
}).then((blob) => {
console.log(imageRef.toString());
uploadBlob = blob
imageRef.put(blob, {
contentType: mime
})
console.log('phase 2');
console.log(imageRef.toString());
console.log(imageRef.getDownloadURL());
imageRef.getDownloadURL()
}).catch((error) => {
console.log(error.toString());
})
}`
代码基于此项目的https://github.com/dailydrip/react-native-firebase-storage/blob/master/src/App.js#L43-L69
发布于 2020-03-13 19:47:37
下面的代码将URL转换为base64图像
RNFetchBlob.fetch("GET", "ImageURL").then(resp => {
base64image.push("data:image/png;base64," + resp.data);
console.log(base64image); // -> your base64 image
});https://stackoverflow.com/questions/43492939
复制相似问题