我正在尝试下载文件并将该文件保存在 iOS 中。我正在使用ionic-native-file插件来实现这一点。该文件已下载,但我在设备中找不到该文件。
filewrite = (): void => {
let transfer = this.fileTransfer.create();
let path = "";
let dir_name = 'Download';
let file_name = "Sample.pdf";
if (this.platform.is('ios')) {
this.platform.ready().then(() => {
path = this.file.documentsDirectory;
this.file.writeFile(path,file_name,this.pdfSrc).then((entry) => {
this.showAlert("download completed");
}, (error) => {
this.showAlert("Download Failed.");
}).catch(err=>{
this.showAlert("Download Failed catch.");
this.showAlert(err.message);
});
}
)
}
};
下载完成提示显示,下载路径为:
file:///var/mobile/Containers/Data/Application/6DE22F30-5806-4393-830A-14C8A1F320BE/Library/Cloud/Sample.pdf
但我在设备中找不到那个位置。然后,我谷歌并在这里看到了。
cordova.file.documentsDirectory - 应用程序专用的文件,但对其他应用程序有意义(例如 Office 文件)。请注意,对于 OSX,这是用户的 ~/Documents 目录。(iOS、OSX)
所以,我实际上看不到该文件,因为它是应用程序私有的。然后我在同一个链接中看到:
所以,我在我的 config.xml 中尝试了这两种偏好,但什么也没发生。
是否有任何方法可以下载文件 iOS 或 Dropbox 或其他任何地方?
