gpt4 book ai didi

angular - ionic 3 - FileTransfer 无法下载文件

转载 作者:太空狗 更新时间:2023-10-29 19:27:38 28 4
gpt4 key购买 nike

在 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
});
}

但是现在我在我的 android 手机中寻找这个文件,但我找不到它。我手机里的路径是enter image description here没有文件。我在哪里下载的?

最佳答案

在第二个参数中使用 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/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com