【发布时间】:2020-10-20 09:34:06
【问题描述】:
我正在努力从 post api 读取 PDF 数据(不是 pdf url),并使用我的 IONIC 4 android 应用程序中安装在手机上的 pdf 查看器打开 pdf。我的文件传输插件在下载该文件时给出错误代码 2。这是我编写的代码。我可以知道我哪里出错了吗?
my.ts 文件
var apiData="https://kairavforex.com/media/documents/reports/hello_TYUtZF5.pdf";
var sdsn={
path:apiData
}
this.http.post('https://kairavforex.com/api/download_report/',sdsn,{'Content-Type': 'application/json','Authorization': "Token" + " " + this.authToken})
.then(data=>{
console.log(data.data)
const fileTransfer: FileTransferObject = this.transfer.create();
fileTransfer.download(data.data, this.file.externalDataDirectory + 'file.pdf').then((entry) => {
this.fileOpener.showOpenWithDialog(entry.toURL(), 'application/pdf')
.then(() => console.log('File is opened'))
.catch(e => console.log('Error opening file', e));
}, (error) => {
console.log(error)
});
})
【问题讨论】:
标签: angular ionic-framework ionic4 angular8