使用filetransfer插件下载无法正常工作 [英] Download not working using filetransfer plugin

查看:1002
本文介绍了使用filetransfer插件下载无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用IonicNative插件下载pdf文件。

I used IonicNative plugin for downloading pdf files.

https://ionicframework.com/docs/native/file-transfer/

我可以看到使用警报完成下载,但是看不到任何下载。

I can see download complete using alert,but cannot see any download happening.

private filetransfer: FileTransferObject = this.transfer.create(); 
  const url = 'https://www.example.com/example%20test.pdf'; 
  this.filetransfer.download(url, this.file.dataDirectory + 'example%20test.pdf').then((entry) =>
          {
                  alert('download complete: ' + entry.toURL());
          },
 (error) => {
                  alert(error);
});

这是正确的做法还是我错过了一些东西?

Is this the correct way to do or am I missing some thing?

推荐答案

这看起来是正确的方法。

This looks like the correct way to do it.

我不会放弃确定是什么你的意思是你看不到任何下载发生,但我假设你在文件系统中找不到该文件(否则只是让我知道)。

I'm not quit sure what you mean with "you cannot see any download happening", but I'm assuming you can't find the file in the file system (otherwise just let me know).

在这种情况下,您将文件保存在私人数据存储中,由以下人员指定:

In this case your saving the file in a private data storage, specified by:

this.file.dataDirectory

如果用this.file.externalDataDirectory替换this.file.dataDirectory,您将在文件系统中找到该文档(类似于:file:///storage/emulated/0/Android/data/com.project.name)。

If you replace this.file.dataDirectory with this.file.externalDataDirectory, you will find the document in your file system (something like: file:///storage/emulated/0/Android/data/com.project.name).

离子原生文档在这方面不是很好例如,请参阅cordova文件插件文档,其中列出了不同的可能性:

The ionic native documentation is not that good in this case, see the cordova file plugin documentation instead, where the different possibilitiers are listed:

https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-file/ #where-to-store-files

这篇关于使用filetransfer插件下载无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆