我正在使用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
問題
任何人都可以說出我在做什麼錯在哪裏? 謝謝。