【发布时间】:2018-03-23 08:07:08
【问题描述】:
我也有类似的问题: How to download file to Download's directory with Ionic Framework?
我在下载后收到成功警报,但在成功下载后显示的路径下的 Android 文件资源管理器中看不到该文件:file:///data/user/0/io.ionic.fileTest/image.jpg
我的代码:
download(){
const fileTransfer: FileTransferObject = this.transfer.create();
const url = "http://cdna.allaboutvision.com/i/conditions-2016/heterochromia-kate-bosworth-660x660-with-credit.jpg";
fileTransfer.download(url, this.file.dataDirectory + 'laska.jpg', true).then((entry) => {
const alertSuccess = this.alertCtrl.create({
title: `Download Succeeded!`,
subTitle: `was successfully downloaded to: ${entry.toURL()}`,
buttons: ['Ok']
});
alertSuccess.present();
}, (error) => {
const alertFailure = this.alertCtrl.create({
title: `Download Failed!`,
subTitle: `was not successfully downloaded. Error code: ${error.code}`,
buttons: ['Ok']
});
alertFailure.present();
});
}
我可以设法将这个文件保存在“下载”文件夹或“文档”中吗?我还尝试将目标路径更改为:
cordova.file.externalRootDirectory + '/Download/'
在这种情况下,我收到错误 1。
在许多示例中,我看到人们使用 window.requestFileSystem() 但看起来窗口对我来说没有这种方法。我使用 Visual Studio 代码和 ionic 3。
【问题讨论】:
标签: javascript android cordova ionic-framework ionic3