我正在使用Ionic和Cordova,我想让我的用户可以下载PDF文件到他们的(根)/ Download文件夹。现在它保存在应用程序的数据文件夹中,但很难到达那里,就像在内部一样。Codova,我可以下载一个文件到(root)/下载文件夹吗?
现在我的代码是这样的,
let destination = `${cordova.file.externalCacheDirectory}my_app/${fileName}`;
,我试图用 'externalRootDirectory',
let destination = `${cordova.file.externalRootDirectory}Download/${fileName}`;
,但不起作用。我认为我的应用程序无法访问该文件夹。
而且我想这一点,
window.requestFileSystem(1, 0, (fs: any) => {
fs.root.getFile('Download/test.pdf', { create: true, exclusive: false }, (fileEntry: any) => {
this.$cordovaFile.writeFile('Download/test.pdf', media.src, 'TEST');
});
});
但FS点到应用程序的数据文件夹。而不是根目录下的下载文件夹。可以访问根目录下的下载文件夹吗?
您正在使用哪种语言? – Homen
我正在使用Ionic和angular1.4 –
我不知道如何写在angular.But当你写'let destination = cordova.file.externalRootDirectory +“/ Download /”+ yourFileName;'在JavaScript中它将工作 – Homen