我正在使用Ionic和Cordova,我想让我的用户可以将PDF文件下载到他们的(根)/ Download文件夹中。目前,它保存在应用程序的数据文件夹中,但很难到达那里,就像深入内部一样。
现在我的代码是这样的,
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指向应用程序的数据文件夹。而不是根目录下的Download文件夹。是否可以访问根目录下的“下载”文件夹?
进入settings->App Manager->Your app->Permissions
。而让storage
permission.Cordova文件插件android.You不完全支持runntime权限的用户可以更改该插件支持it.You可以检查此引用知道你能如何对待的链接。首先,请确保<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
Android Manifest文件中有该文件。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句