Codova,我可以将文件下载到(root)/ Download文件夹吗?(Codova, can I download a file to (root)/Download folder?)

编程入门 行业动态 更新时间:2024-10-20 09:22:35
Codova,我可以将文件下载到(root)/ Download文件夹吗?(Codova, can I download a file to (root)/Download folder?)

我正在使用Ionic和Cordova,我想让我的用户可以将PDF文件下载到他们的(root)/ 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文件夹。 是否可以访问根目录下的“下载”文件夹?

I'm using Ionic and Cordova, and I want make my user could download a PDF file to their (root)/Download folder. For now it saves on application's data folder, but it's hard to get there, it's like deep inside.

For now my code is like this,

let destination = `${cordova.file.externalCacheDirectory}my_app/${fileName}`;

and I tried with 'externalRootDirectory',

let destination = `${cordova.file.externalRootDirectory}Download/${fileName}`;

but that doesn't work. I think my app doesn't have a access to the folder.

Also I tried this,

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'); }); });

But the fs points to the application's data folder. not the Download folder right under the root. Is that possible to access the Download folder that under the root directory?

最满意答案

转到settings->App Manager->Your app->Permissions 。并启用storage权限.Cordova文件插件不完全支持android的runntime权限。您可以更改插件以支持它。您可以检查此引用以了解如何接近链接 。 首先确保在Android Manifest文件中有<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> 。

Go to settings->App Manager->Your app->Permissions.And enable storage permission.Cordova file plugin not fully Support runntime permission of android.You can change the plugin to support it.You can check this reference to know how you can approach link. At first make sure <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> is there in Android Manifest file.

更多推荐

Download,root,文件夹,folder,电脑培训,计算机培训,IT培训"/> <meta name="desc

本文发布于:2023-07-22 09:57:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1219157.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文件夹   文件   root   Codova   Download

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!