1

I'm developing a chrome app with the capability to handle files. I need to copy these files to the app, which I believe stores it in the app's sandbox.

But where are these files, like on my disk?

Here's where I get access to the filesystem:

fs = null

oneGig = Math.pow 2, 30 # 1GB
window.webkitRequestFileSystem window.PERSISTENT, oneGig,
  (_fs) -> # on fs init
    fs = _fs
    console.log fs.root.fullPath #=> "/" obviously not right

  (e) -> # on fs error
    console.log e

Followed by this code to actually write the files.

fs.root.getFile songObj.md5, create: true, (fileEntry) ->
  fileEntry.createWriter (fileWriter) ->
    fileWriter.onwriteend = (e) ->
      console.log 'Song file saved!', fileEntry, e

      # Where the hell on disk is my file now?

    fileWriter.onerror    = (e) ->
      console.log 'fileWriter.onerror', e

    fileWriter.write songObj.blob

  , (e) -> console.log 'fileEntry.createWriter error', e
, (e) -> console.log 'fs.root.getFile error', e

I've had some bugs in my file handling and want to be able to easily inspect what is going on, as well as clean things up if necessary. And I can't seem find anywhere in the docs that it says files go. And this especially frustrating since I'm have files just vanish after coming back to the app a few days later.

Alex Wayne
  • 178,991
  • 47
  • 309
  • 337
  • 1
    The sandbox is obfuscated. The files are programmatically available only through the API. This doesn't appear to be a requirement of the spec (http://dev.w3.org/2006/webapi/FileAPI/), but it makes sense from a security perspective. Of course, the data does live on your local disk, but in a weird format. It'd be easier to fix your code than figure out that format. Why don't you ask a new question that directly addresses the issue of why your files disappear? – sowbug Jan 19 '14 at 16:44
  • 2
    Also, check out http://stackoverflow.com/a/11497638/65977 which lets you inspect the filesystem from the Chrome DevTools. – Tyler Jan 20 '14 at 21:49

2 Answers2

4

They go into a "sandbox" which isn't easy to inspect. You might want to instead use the new chrome.fileSystem chooseEntry function (http://developer.chrome.com/apps/fileSystem.html) with the "directory" option and also "retainEntry" to get access to write to a normal directory on your computer, so that you can see the files and have them not be cleared out when you clear your browser cache, etc.

kzahel
  • 2,765
  • 1
  • 22
  • 31
2

So I'm not entirely sure at the lower level how Chrome Apps differ from a normal web-page, in the contect of the HTML5 Filesystem API.

But I can say that persistent storage On Windows 7, with Chrome is here:

C:\Users\{user}\AppData\Local\Google\Chrome\User Data\Default\File System\

If you want to find out where it is stored via Chrome on other OS please see this_post

Note, the directory names are weird, that said though the underlying file contents and sizes are exactly the same, so if you poke around the files and open in a text editor you'll be able to see the original contents of your files before you copied them into the persistent web-app space.

Community
  • 1
  • 1
Arthur Weborg
  • 8,280
  • 5
  • 30
  • 67