【发布时间】:2016-07-29 15:20:59
【问题描述】:
我正在使用react-native-fs,我正在尝试将 pdf 文件的 base64 保存到我的 android 模拟器文件系统。
我从服务器收到 base64 编码的 pdf。
然后我使用以下行解码 base64 字符串:
var pdfBase64 = 'data:application/pdf;base64,'+base64Str;
saveFile() 函数
saveFile(filename, pdfBase64){
// create a path you want to write to
var path = RNFS.DocumentDirectoryPath + '/' + filename;
// write the file
RNFS.writeFile(path, base64Image, 'base64').then((success) => {
console.log('FILE WRITTEN!');
})
.catch((err) => {
console.log("SaveFile()", err.message);
});
}
错误
当我尝试保存 pdfBase64 时,saveFile() 函数会捕获以下错误:
bad base-64
问题
谁能告诉我在哪里或我做错了什么?
谢谢。
【问题讨论】:
标签: react-native base64 react-native-android react-native-fs