我正在使用react-native-fs,我试图将pdf文件的base64保存到我的android模拟器文件系统。如何将pdf保存到android文件系统,然后查看PDF - react-native
我从服务器收到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
问题
任何人都可以说出我在做什么错在哪里? 谢谢。