How does the Filesystem API work in Chromium OS?

792 views
Skip to first unread message

Daniel Tse

unread,
May 19, 2014, 1:51:37 PM5/19/14
to chromi...@chromium.org
Hi There,

Am I correct in understanding that the FileSystem in Chromium OS (ChromeOS / Chromebooks) is sandboxed/limited to just the packaged app for security reasons?

Currently, my packaged app asks a user to pick a "Save" directory via chrome.fileSystem.chooseEntry where the app will save all the generated files.

I cache the FileEntry so that the user doesn't need to select this directory each time. My app then generates a file and then saves it in that directory.

I'm getting reports that this isn't working in Chromium OS. The users report that the files aren't being saved anywhere that they can tell. I've tested on Windows/Mac/Linux and have not seen any troubles. 

What is the best approach to using the FileSystem API in Chromium? Is it purely for read-only? I don't have a chromebook, I had assumed that users could save downloaded files to their local storage <- incorrect assumption?

Thanks!
-Daniel

David Brodbeck

unread,
May 20, 2014, 2:39:01 AM5/20/14
to Daniel Tse, Chromium Apps
I use this API, and it works fine on my Chromebook.  I'm able to save to the Downloads folder, an external drive, or Google Drive with it, and fileEntries seem to be retained OK.  Those are really the only three places that ChromeOS lets you save things, so I'm not sure how something could "go missing."

Now, ChromiumOS and ChromeOS do have differences, and I haven't tested under the Chromium build.  You might want to grab a copy to test with.  You can get pre-built images for x86 hardware here: http://chromeos.hexxeh.net/
It will run quite nicely off a USB stick for test purposes.  It's worth trying just to see how your app looks with the Chromium UI; there are differences in how icon alerts and notifications are displayed compared to other OS's.



--
You received this message because you are subscribed to the Google Groups "Chromium Apps" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-app...@chromium.org.
To post to this group, send email to chromi...@chromium.org.
Visit this group at http://groups.google.com/a/chromium.org/group/chromium-apps/.
For more options, visit https://groups.google.com/a/chromium.org/d/optout.



--
GPG Key Fingerprint: 0DB7 4B50 8910 DBC5 B510 79C4 3970 2BC3 2078 D875

Max Waterman

unread,
May 20, 2014, 6:20:18 AM5/20/14
to chromi...@chromium.org, Daniel Tse
I wonder if someone could be explicit about which API we're talking about via a link - there are a few that could be described as filesystem, though I do note you used a capital 'F', so I might assume something from that.

Anyway, I had thought that there was essentially no access to the filesystem outside a sandbox, so I'd be quite interested to know more about this. I have been listening to the Google presentation about the SyncFilesystem API :


which says it only works inside a sandbox, even though that sandbox is stored on Google Drive.
I also see :


which also says it is in a sandbox.

The presentation I watched, also mentioned that the synced sandbox is removed if the app is removed - :/

Anyway, I do notice this :

"
Note: Unlike regular Filesystem API, Chrome's Sync Filesystem API currently does NOT support directory operations, except for reading directory entries in the root directory. An attempt to create a directory in Sync Filesystem will result in INVALID_MODIFICATION_ERROR.
"

which makes me think that the 'regular Filesystem API' might be a different kettle of fish and I suppose I really need to just try them to find out.

However, I'm clearly in some confusion, so if you can elaborate/illuminate, that'd be great ;)

Thanks!

Max.

Daniel Tse

unread,
May 20, 2014, 11:35:29 AM5/20/14
to chromi...@chromium.org, Daniel Tse
Thanks for your reply! I'm downloading an image from hexxeh.net as we speak! (luckily my app only uses APIs from Chrome 28 so my app should work). You're right about testing in a different UI, I was trying to properly build my own Chrome OS but that seems to be taking longer than I had hoped).

Daniel Tse

unread,
May 20, 2014, 11:52:21 AM5/20/14
to chromi...@chromium.org, Daniel Tse
Thanks Max,

I am using https://developer.chrome.com/apps/fileSystem as the FileSystem API (I apologize for not being specific earlier :) )

The note seems to refer to the ability to perform directory operations (like creating/deleting/renaming directories). I'm using 

chrome.fileSystem.chooseEntry(object options, function callback)

to get the user to select a directory (and then I cache the fileEntry selected).

It seems to be a problem after the user has selected the directory and my app tries to write a file using

 chrome.fileSystem.getWritableEntry(fileEntry, function(entry) {
                entry.getFile(fileName, {create:true}, function(entry) {

No error is flagged and no file is actually written. Hopefully I'll be able to debug using the ChromeOS Image.

Thanks again!
-Daniel

Ben Wells

unread,
May 20, 2014, 7:00:55 PM5/20/14
to Daniel Tse, Chromium Apps
Hi Daniel,

I don't know what the doc means by saying sandboxed, I believe it is an error and will correct it (http://crbug.com/375508).

As Max has mentioned chrome.fileSystem should Just Work on ChromeOS. It should allow access to the drive and downloads folders. If you find something that doesn't work please file a bug at crbug.com.

Cheers
Ben.

Ben Wang

unread,
May 20, 2014, 8:31:25 PM5/20/14
to chromi...@chromium.org
I have not used chrome.fileSystem, but I think the problem may you can't "cache" the entry to save file later, all save operation must get called from a user's action, like click a button. it's like HTML5 FileSaver.

Matt Giuca

unread,
May 20, 2014, 9:14:36 PM5/20/14
to Ben Wang, Chromium Apps
@Ben Wang: This is not true. The chrome.fileSystem API (unlike HTML5 file dialogs) does let you retain access to a file entry you have opened so that you can continue using it on subsequent runs of the app without requiring user interaction.

See chrome.fileSystem.retainEntry and note that it requires an explicit "retainEntries" permission.


--

Ian Clelland

unread,
May 21, 2014, 8:44:18 AM5/21/14
to Ben Wells, Daniel Tse, Chromium Apps
I believe that the "sandbox" described in the chrome.fileSystem case refers to the fact that when a user grants access to a directory with c.f.chooseEntry, the application cannot access any files outside of that directory.

It's a different use of the term than in the File API -- both sandboxes prevent the application from accessing files outside of a defined area, but the File API sandbox also prevents applications from interacting with each other, or with files that they did not create themselves.

The chrome.fileSystem sandbox isn't so restrictive. If the user chooses, they can grant access to any file or directory on the filesystem, but the application still has a well-defined area that it must "play inside".

Ian

Daniel Tse

unread,
May 21, 2014, 5:04:53 PM5/21/14
to chromi...@chromium.org, Ben Wells, Daniel Tse, icle...@chromium.org
Hi All,

Thanks so much for everyone chiming in! 

I was able to get one of Hexxeh's Chromium Builds (28.0.1484.1) to load in VirtualBox and tested my app. 

On this build, I was able to see that on this build ChromeOS-Vanilla-4028.0.2013_04_20_1810-r706c4144-VirtualBox the call to chrome.fileSystem.chooseEntry({type:'openDirectory'} does not open a dialog. However, if you set the {type:'openFile'} the dialog does open.

How does one debug an app on a Chromebook/Chromium? I have uploaded my unpacked Packaged App onto Google Drive but I don't see a way to access that folder from the Load Unpacked Extension dialog (Google Drive is not listed anywhere). I'd like to see what's happening before filing the bug.

-Dan

David Brodbeck

unread,
May 21, 2014, 6:37:47 PM5/21/14
to Daniel Tse, Chromium Apps, Ben Wells, icle...@chromium.org
I usually zip up the app directory and put the ZIP file on Google Drive.  On ChromeOS you can drag file from Drive into the Downloads folder using the file manager.  You can then extract the files (ChromeOS has ZIP support built in) and load them as an unpackaged app.

It makes sense that I wouldn't have encountered the issue you're seeing; I don't use openDirectory in my app.


--
You received this message because you are subscribed to the Google Groups "Chromium Apps" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-app...@chromium.org.
To post to this group, send email to chromi...@chromium.org.
Visit this group at http://groups.google.com/a/chromium.org/group/chromium-apps/.
For more options, visit https://groups.google.com/a/chromium.org/d/optout.

Daniel Tse

unread,
May 21, 2014, 7:07:12 PM5/21/14
to chromi...@chromium.org, Ben Wells, icle...@chromium.org
Thanks for the tip Orville!

So an update:

After trying to load my app, I discovered that it flagged a few warnings:
  • Permission 'fileSystem.retainEntries' is unknown or URL pattern is malformed.
  • Permission 'fileSystem.directory' is unknown or URL pattern is malformed.
  • Permission 'identity' is unknown or URL pattern is malformed.
I believe that these warnings are being flagged because retainEntry is definitely Chrome 31 (and onwards) and 
chrome.fileSystem.chooseEntry('openDirectory' has a note that says it's also new in Chrome 31. 

This basically means that I need to get/build a more recent version of chromium/ChromeOS right before I can debug further? It seems like Hexxeh's builds stopped after he joined Google, are there no other existing images to quickly download and run? I have Linux I could run qemu! I just don't want to build the entire image.

-Dan

Ben Wells

unread,
May 21, 2014, 7:15:06 PM5/21/14
to Daniel Tse, Chromium Apps, icle...@chromium.org
On Thu, May 22, 2014 at 9:07 AM, Daniel Tse <danp...@gmail.com> wrote:
Thanks for the tip Orville!

So an update:

After trying to load my app, I discovered that it flagged a few warnings:
  • Permission 'fileSystem.retainEntries' is unknown or URL pattern is malformed.
  • Permission 'fileSystem.directory' is unknown or URL pattern is malformed.
  • Permission 'identity' is unknown or URL pattern is malformed.
I believe that these warnings are being flagged because retainEntry is definitely Chrome 31 (and onwards) and 
chrome.fileSystem.chooseEntry('openDirectory' has a note that says it's also new in Chrome 31. 

That would explain it.

Is your app on the webstore? I have a chromebook and can have a quick look it if helps.
 

This basically means that I need to get/build a more recent version of chromium/ChromeOS right before I can debug further? It seems like Hexxeh's builds stopped after he joined Google, are there no other existing images to quickly download and run? I have Linux I could run qemu! I just don't want to build the entire image.

-Dan

On Wednesday, May 21, 2014 4:37:47 PM UTC-6, Orville wrote:
I usually zip up the app directory and put the ZIP file on Google Drive.  On ChromeOS you can drag file from Drive into the Downloads folder using the file manager.  You can then extract the files (ChromeOS has ZIP support built in) and load them as an unpackaged app.

It makes sense that I wouldn't have encountered the issue you're seeing; I don't use openDirectory in my app.


On Wed, May 21, 2014 at 2:04 PM, Daniel Tse <danp...@gmail.com> wrote:
Hi All,

Thanks so much for everyone chiming in! 

I was able to get one of Hexxeh's Chromium Builds (28.0.1484.1) to load in VirtualBox and tested my app. 

On this build, I was able to see that on this build ChromeOS-Vanilla-4028.0.2013_04_20_1810-r706c4144-VirtualBox the call to chrome.fileSystem.chooseEntry({type:'openDirectory'} does not open a dialog. However, if you set the {type:'openFile'} the dialog does open.

How does one debug an app on a Chromebook/Chromium? I have uploaded my unpacked Packaged App onto Google Drive but I don't see a way to access that folder from the Load Unpacked Extension dialog (Google Drive is not listed anywhere). I'd like to see what's happening before filing the bug.

-Dan


On Wednesday, May 21, 2014 6:44:18 AM UTC-6, Ian Clelland wrote:
I believe that the "sandbox" described in the chrome.fileSystem case refers to the fact that when a user grants access to a directory with c.f.chooseEntry, the application cannot access any files outside of that directory.
 
That might be it. I probably wrote that little intro a couple of years ago ... I can't remember what I was thinking :/ For now I think it is more confusing than helpful so will revisit it.

Daniel Tse

unread,
May 21, 2014, 7:18:25 PM5/21/14
to chromi...@chromium.org, Daniel Tse, icle...@chromium.org
Thanks!

It's on the webstore here (shortened-link): http://bit.ly/easyphotobooth

-Daniel

Ben Wells

unread,
May 22, 2014, 1:17:14 AM5/22/14
to Daniel Tse, Chromium Apps, icle...@chromium.org
The app worked fine for me. I could take some pictures and save them into my Downloads folder.

Could it be the users with problems don't know that there is a files app on ChromeOS? You could try asking them where they looked.

David Brodbeck

unread,
May 22, 2014, 1:32:06 AM5/22/14
to Daniel Tse, Chromium Apps, Ben Wells, icle...@chromium.org
On Wed, May 21, 2014 at 4:07 PM, Daniel Tse <danp...@gmail.com> wrote:
It seems like Hexxeh's builds stopped after he joined Google, are there no other existing images to quickly download and run? I have Linux I could run qemu! I just don't want to build the entire image.

Ah, my bad, I failed to notice he'd stopped.  That's a shame, it's quite a time-consuming build and having his pre-built ones was really handy.

Daniel Tse

unread,
May 22, 2014, 11:25:14 AM5/22/14
to chromi...@chromium.org, Ben Wells, icle...@chromium.org
Thank you for testing it out on your Chromebook Ben, I really appreciate it!

So after a bit of back/forth with the users somehow.... (I'm not exactly sure how) for two separate users their Chromebooks were out of date and running an older version of Chrome and another had a lack of knowledge of the files app (and how it works) on Chrome. I had incorrectly assumed that they had a level of familiarity with the Chrome Platform.

As a result, I realize a few things: 
  • I need to increase the minimum_chrome_version in my manifest from 28 to 31 to accommodate for the File Permissions - this ought to filter out older versions of Chrome/ChromeOS (right?)
  • definitely need to get recent build of ChromeOS (hexxeh's builds stop at 28 we're now at 35)
  • I may need a way to save to Google Drive/Docs in my app rather than save on the File System
  • I may need a separate set of instructions/guides for each platform i.e. Chrome Users experience file/directory management very differently from Windows/Mac users
Thanks again everyone! I really appreciate all the insights and discussion.
-Daniel

Ben Wells

unread,
May 22, 2014, 6:35:04 PM5/22/14
to Daniel Tse, Chromium Apps, icle...@chromium.org
On Fri, May 23, 2014 at 1:25 AM, Daniel Tse <danp...@gmail.com> wrote:
Thank you for testing it out on your Chromebook Ben, I really appreciate it!

So after a bit of back/forth with the users somehow.... (I'm not exactly sure how) for two separate users their Chromebooks were out of date and running an older version of Chrome and another had a lack of knowledge of the files app (and how it works) on Chrome. I had incorrectly assumed that they had a level of familiarity with the Chrome Platform.

As a result, I realize a few things: 
  • I need to increase the minimum_chrome_version in my manifest from 28 to 31 to accommodate for the File Permissions - this ought to filter out older versions of Chrome/ChromeOS (right?)
  • definitely need to get recent build of ChromeOS (hexxeh's builds stop at 28 we're now at 35)
There are ways to run chromeos on Windows. It is now our metro mode thing and there is apparently some way to run this on Windows 7 as well (I think the flag --open-ash, although when I tried it it crashed on trunk (i.e. a chrome I built myself from the latest source)).
 
  • I may need a way to save to Google Drive/Docs in my app rather than save on the File System
In case you're not aware, on chromeos there is a drive folder. The file system API supports reading / writing to that, so your users should be able to write to drive that way. 

Daniel Tse

unread,
May 23, 2014, 12:35:41 AM5/23/14
to chromi...@chromium.org, Daniel Tse, icle...@chromium.org
Hi Ben,

I tried testing ChromeOS in Metro mode (that was my first impulse!) however, the File System calls in Metro Mode still use the Windows File Dialog. The users were reporting their File Dialog issues in ChromeBook and I felt/feel that I needed to try and see what they were seeing.

I was thinking there ought to be a Drive folder in Chrome (maybe this is in a later ChromeOS versions compared to 28)
Reply all
Reply to author
Forward
0 new messages