Chrome应用程序:如何枚举静态文件夹下的文件? [英] Chrome App: How to enumerate files under a static folder?
问题描述
开发Chrome应用程序时,如何枚举静态文件夹下的文件(例如存储应用程序使用的所有静态图像的图像)?
How can I enumerate files under a static folder (such as images where all the static images used by my app are stored) while developing a chrome app?
我尝试过的事情:
-查看了这些链接 1 ,此链接.但是我的应用需要能够枚举静态文件夹下的所有文件,而不会提示用户任何操作/权限.
What I have tried:
- looked at these links 1, 2. i am not trying to read from local or user storage. i want to read from static storage. static storage are the folders where an app stores its static contents - assets like images, css, js etc.
- looked at this link. but my app needs to be able to enumerate all files under a static folder without prompting the user for any action/permission.
我将举一个为什么有用的例子.想象我想发布一个应用程序,用户可以使用它来阅读我的诗歌.我想要一个静态文件夹,用于保存自己写的诗.然后当我写新诗时,这些诗就应该自动可用,而不必进行任何代码更改.此外,我能够在android上执行此操作而无需任何用户提示,因此希望chrome平台也应支持此操作-不能有任何安全借口.
i will give an example of why this is useful. imagine i want to release an app using which users can read my poems. i want a static folder where i save poems i write. then as i write new poems, these poems should then be made available automatically without having to do any code changes. further i was able to do this on android without any user prompt whatsoever so expect chrome platform should also support this - there cannot be any security excuses.
推荐答案
If you are looking to enumerate app's own files, it's possible via chrome.runtime.getPackageDirectoryEntry
.
它会为您的应用的根目录返回一个DirectoryEntry
,您可以在其中导航和迭代.
It returns a DirectoryEntry
for the root of your app that you can navigate and iterate through.
请参阅以下问题: 查看全文