在 angular/ionic 应用程序中,我有以下代码可以从互联网下载 pdf。
public pdfDownload(){
const fileTransfer: FileTransferObject = this.transfer.create();
const mime = 'application/pdf';
const pdfFile = 'http://www.pdf995.com/samples/pdf.pdf';
// alert(this.file.dataDirectory);
fileTransfer.download(pdfFile, this.file.dataDirectory + 'file.pdf', true)
.then((entry) => {
alert('download complete: ' + entry.toURL());
}, (error) => {
// handle error
});
}
最佳答案
在第二个参数中使用 this.file.externalDataDirectory+'file.pdf' 而不是 this.file.dataDirectory+'file.pdf'函数fileTransfer.download(1个参数,2个参数,3个参数);
例如
fileTransfer.download(pdfFile, this.file.externalDataDirectory + 'file.pdf', true)
关于angular - ionic 3 - FileTransfer 无法下载文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47561737/