我正在使用ionic 3上的Download插件从外部来源本地下载pdf文件。这是我正在使用的代码。
var request = {
uri: item.url,
title: item.resource_title,
description: '',
mimeType: '',
visibleInDownloadsUi: false,
notificationVisibility: 1,
destinationInExternalFilesDir: {
dirType: 'Downloads',
subPath: 'MyFile.pdf'
},
destinationUri: 'this.file.externalRootDirectory + ‘/Download/’',
};
this.downloader.download(request)
.then((location: string) => console.log('File downloaded at:'+location))
.catch((error: any) => console.error(error));
在上面的代码“ item.uri”中是一个外部下载链接,例如onedrive.com/demo.pdf
现在的问题是,每当用户下载此文件时,他都可以在下载管理器中看到源URL(onedrive.com/demo.pdf)。
我当时想有办法在下载管理器中我们可以隐藏此源uri或显示一些虚拟文本。我可以看到其他类似Google和Skype的应用程序也可以做到这一点。
您好,找到了下载到本地存储或外部存储的解决方案,如果让我知道我也遇到相同的问题,这是我的代码
var request: DownloadRequest = {
uri: that,
title: this.fileName,
description: '',
mimeType: '',
visibleInDownloadsUi: true,
notificationVisibility: NotificationVisibility.VisibleNotifyCompleted,
destinationInExternalFilesDir: {
dirType: 'Download',
subPath: ''
},
destinationInExternalPublicDir: {
dirType: this.file.externalRootDirectory + `Download/`,
subPath: ''
},
destinationUri: this.file.externalRootDirectory + `Download/`,
};
this.downloader.download(request)
.then((location: string) => console.log('File downloaded at:' + location))
.catch((error: any) => console.error(error));
});