Reputation: 216
I am new in chrome app development,I have developed desktop based app few days back using NW , Now i want to developed same app for chrome.
Here what i want to achieve -
1.Create folder (named same as app name) in user's local file-system,when app installed.
2.Storing/Accessing files and folders inside above folder.
are these problems can be solved by chrome's file-system API? if YES then please suggest me the way.
BTW , I have tried to access file-system api and my manifest file look like below-
{
"manifest_version": 2,
"name": "sampleApp",
"short_name": "sampleApp",
"description": "A Sample APP",
"version": "0.0.1",
"minimum_chrome_version": "38",
"icons": {
"16": "assets/images/icon_16.png",
"128": "assets/images/icon_128.png"
},
"permissions": [
{"fileSystem": ["write", "retainEntries", "directory","requestFileSystem"]},
"unlimitedStorage",
"system.network",
"storage"
],
"app": {
"background": {
"scripts": ["main.js"]
}
}
}
When i run my app and try to access file system api i see warning in chrome extension area-
Note : I am using win 10.
fileSystem.requestFileSystem' is not allowed for specified platform
Upvotes: 2
Views: 280
Reputation: 77482
requestFileSystem
is the wrong API to use:
Available to kiosk apps running in kiosk session only.
You should just call fileSystem.chooseEntry
to ask the user where he wants that folder created, and then retain that entry so you don't need to ask for permission again.
There is no way to NOT ask the user through chooseEntry
, but you can do this only once.
A good fileSystem
API sample is provided by Google.
Note, you can silently request access to your App's install folder (as you ask in the title) with chrome.runtime.getPackageDirectoryEntry
. However, this access is read-only.
And if you ever modify that folder, no matter how, Chrome will promptly disable your app as "compromised", as it keeps signed hashes of all files downloaded from Chrome Web Store.
As a potential solution, you can request a virtual filesystem before prompting the user if you don't want that prompt to be the first thing your app does. But to write out to disk you'll need the prompt. So it makes little sense to overcomplicate it this way - explain to the user that you need him/her to select a save location.
Upvotes: 3