如何在react native中下载base64到pdf



我想从base64字符串下载pdf文件。我想在不使用提取的情况下完成,因为我会在下载之前提取数据。

尝试包获取blob。首先下载base64数据,然后将其作为文件保存到设备存储中。您可以从fetch blob中获取资产uri并显示它。

RNFetchBlob
.config({
fileCache : true,
// by adding this option, the temp files will have a file extension
appendExt : 'png'
})
.fetch('GET', 'http://www.example.com/file/example.zip', {
//some headers ..
})
.then((res) => {
// the temp file path with file extension `png`
console.log('The file saved to ', res.path())
// Beware that when using a file path as Image source on Android,
// you must prepend "file://"" before the file path
imageView = <Image source={{ uri : Platform.OS === 'android' ? 'file://' + res.path()  : '' + res.path() }}/>
})

我希望它会有所帮助。

最新更新