Chrome app: read file in hard drive

166 views
Skip to first unread message

Stefano Corradi

unread,
May 12, 2015, 1:05:19 PM5/12/15
to chromi...@chromium.org

What is the best way to read (and use) files (json/audio/video) stored on the local hard disk (not in the application folder es file:///myFolder/myVideo.mp4) with a chrome app?

thank you!

Victor Khimenko

unread,
May 12, 2015, 1:13:09 PM5/12/15
to Stefano Corradi, Chromium Apps
On Tue, May 12, 2015 at 8:05 PM, Stefano Corradi <stefano...@gmail.com> wrote:

What is the best way to read (and use) files (json/audio/video) stored on the local hard disk (not in the application folder es file:///myFolder/myVideo.mp4) with a chrome app?

Uhm... "Best" is kind of wague. Perhaps you could explain why tutorial ( https://developer.chrome.com/apps/app_storage ) haven't helped you to make a decision?

Stefano Corradi

unread,
May 12, 2015, 1:19:02 PM5/12/15
to chromi...@chromium.org, stefano...@gmail.com
the problem is that the files are not stored nell'app_storage but in different locations on the hard disk. These paths are dynamically passed through an external json

thank!

David Brodbeck

unread,
May 12, 2015, 2:15:04 PM5/12/15
to Stefano Corradi, Chromium Apps
I don't think you can do that with the current API.  There's the chrome.fileSystem API, but it requires the user to choose a file directly from a dialog; you can't pass in an arbitrary path.  You *can*, however, retain a user-selected entry and use it again without having to prompt the user a second time.


--
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

Matt Giuca

unread,
May 12, 2015, 8:24:05 PM5/12/15
to David Brodbeck, Stefano Corradi, Chromium Apps
David is correct.

You cannot open an arbitrary path in the user's file system, for security reasons. Otherwise a Chrome App could take full control over a user's machine.

All file access abilities in Chrome Apps are either sandboxed, or require that the user grants permission to access the specific files or folders.

Stefano Corradi

unread,
May 13, 2015, 4:30:30 AM5/13/15
to chromi...@chromium.org, stefano...@gmail.com, gu...@gull.us
Thanks for your answer!
Do you think that would be possible with a chromebook?

David Brodbeck

unread,
May 13, 2015, 1:29:27 PM5/13/15
to Stefano Corradi, Chromium Apps
As far as I know, no.  Chromebooks don't get any fileSystem APIs that aren't available on other platforms.

Matt Giuca

unread,
May 13, 2015, 9:09:07 PM5/13/15
to David Brodbeck, Stefano Corradi, Chromium Apps
Again, David is correct. The whole point of a Chromebook is that all apps are sandboxed and the user's files are safe.

(Besides, ChromeOS doesn't really *have* a file system, just a Downloads folder.)

Dato Da

unread,
May 13, 2015, 10:37:23 PM5/13/15
to chromi...@chromium.org, stefano...@gmail.com, gu...@gull.us
A related question: Can I use the File System API supported by Chrome (described here http://www.html5rocks.com/en/tutorials/file/filesystem/) in a Chrome app? I tried to use it in a Chrome app, like this:

  navigator.webkitPersistentStorage.requestQuota (
    requestedBytes, 
function(grantedBytes) {  
        window.webkitRequestFileSystem(PERSISTENT, grantedBytes, onInitFs, errorHandler); 

    }, 
    function(e) { 
      console.log('Error', e); 
    }
  );


yet the call seems to be a no-op, neither the success handler nor the failure handler was called. Any insight on this behavior would be appreciated. Thanks.
Reply all
Reply to author
Forward
0 new messages