Chrome App - How do I use the FileSystem API to download and store remote files?

250 views
Skip to first unread message

Paul Canning

unread,
Feb 25, 2015, 5:27:31 AM2/25/15
to chromi...@chromium.org
I'm looking to download and store a handful of files (for offline usage) in my Chrome App (packaged, not hosted)

I understand there is a File storage API, but the documentation and sample app on GitHub are pretty poor.

Also, lots of stuff I have read about the HTML5 filesystem API only talks about temporary or persistent storage, yet Chrome Apps can use unlimited, again there is no discussion about this anywhere!

Can anyone point me in the right direction with regards to downloading the files (synchronously, i want them to download then afterwards the app will continue) and storing them (e.g. where to store, how etc) and then reading them back inside the app.

Thanks!

Martin Hodgkins

unread,
Feb 25, 2015, 6:26:57 AM2/25/15
to chromi...@chromium.org
Hi, I know you wanted info on API but would html5 application cache do what you want? Basically the browser caches files locally that you have listed in a config file and then your app can use them offline. You just refer to them as if they were on your server and the browser does the rest. Hope that helps.

Victor Khimenko

unread,
Feb 25, 2015, 8:28:26 AM2/25/15
to Paul Canning, Chromium Apps
On Wed, Feb 25, 2015 at 1:27 PM, Paul Canning <pcan...@gmail.com> wrote:
I'm looking to download and store a handful of files (for offline usage) in my Chrome App (packaged, not hosted)

I understand there is a File storage API, but the documentation and sample app on GitHub are pretty poor.

Also, lots of stuff I have read about the HTML5 filesystem API only talks about temporary or persistent storage, yet Chrome Apps can use unlimited, again there is no discussion about this anywhere!

Unlimited quota is just persistent storage with no quota (only limited by size of client's SSD).
 
Can anyone point me in the right direction with regards to downloading the files (synchronously, i want them to download then afterwards the app will continue) and storing them (e.g. where to store, how etc) and then reading them back inside the app.

Noone could point you "in the right direction" because the think you are asking about just does not exist. All new web APIs are asyncronyous and Filesystem APIs are not an exception. They are designed to work with callbacks, it's your resposibility to cope with this design decision. You could create "preloater" which will load everything and store in different variables or you could design you app to work with callbacks, what you COULDN'T currently do is to create the thing you relly want.

If you understand that then example in the usual place is pretty easy to work with:

Reply all
Reply to author
Forward
0 new messages