我试图从网址下载图像,然后通过什么应用程序和其他社交媒体分享它作为图像格式,我尝试了一些方法,但我不能,我的代码如下:
let filePath = null;
const configOptions = {
fileCache: true,
};
RNFetchBlob.config(configOptions)
.fetch('GET', url)
.then(async resp => {
filePath = resp.path();
let options = {
url: filePath
};
await Share.open(options);
await RNFS.unlink(filePath);
});
我也试过了
RNFetchBlob.fetch("GET",url,{
Authorization : 'Bearer access-token...',
})
.then(resp => {
console.log(resp)
let shareImageBase64 = {
title: "React Native",
message: "Hola mundo",
url: `data:image/png;base64,` + resp.base64(),
};
Share.open(shareImageBase64);
})
它确实打开了共享选项,但没有图像,只能共享消息。
这是github中的一个未解决的问题,这个问题仅在IOS与whats app共享时才会出现。问题是shareImageBase64下的消息会覆盖该URL,并且您只是在共享该消息,解决方法是删除该消息,您将能够成功共享您的映像。