【发布时间】:2023-03-21 05:44:01
【问题描述】:
下午好。 我正在尝试与文本共享图像,但图像未共享,共享时仅显示文本。 我根据其他主题制作了这段代码, 图像正在转换为 base64,但仍然没有出现。 注意:URI 是存储在 firebase 中的图像。
onSharePress() {
const fs = RNFetchBlob.fs;
let imagePath = null;
RNFetchBlob.config({
fileCache: true
})
.fetch("GET", "https://i.kinja-img.com/gawker-media/image/upload/s--HqfzgkTd--/c_scale,f_auto,fl_progressive,q_80,w_800/wp2qinp6fu0d8guhex9v.jpg")
.then(resp => {
imagePath = resp.path();
return resp.readFile("base64");
})
.then(async base64Data => {
var base64Data = `data:image/png;base64,` + base64Data;
// here's base64 encoded image
console.log(base64Data);
const shareOptions = {
title: 'Title',
message: 'Message to share',
url: base64Data,
subject: 'Subject'
};
alert(base64Data);
await Share.share(shareOptions);
return fs.unlink(imagePath);
});
}
【问题讨论】:
标签: react-native firebase-realtime-database