1

I'm developing an application that will allow the user to create his/her own data, and since I don't have a backend or a database, everything just lives on the user's session.

My ideal solution would be the following:

  1. User works with the application, clicks on "Save", gets a download prompt, downloads a file to his/her filesystem
  2. User clicks on "Load", a file input dialog gets shown, user picks his/her file, and the data is back again on the app.

I thought in using the FileSystem API, but it will just work on a sandboxed environment which defeats the ability for the user to work with the data in another browser.

I know I can simulate a download by just stringifying the data dropping it into a window to make a download. However, when I want to load this data again using input type=file, I don't have the ability to read the actual contents of the file, so it's a one-way path.

Some other apps usually just displays the contents of the file to the user and make the user copy/paste content, but I would like to simplify to the user.

Finally, I would like to support at the very least the latest version of desktop browsers.

What option would be the most suitable for this situation?

Community
  • 1
  • 1
Alpha
  • 7,586
  • 8
  • 59
  • 92
  • 1
    you can let people download files using `Blobs`, and then they could just select them again in an input, which you could read from using a `FileReader` (yes, you can get the contents of a file like this) – markasoftware Jun 02 '14 at 23:58

1 Answers1

2

You should offer files for download, then read them from <input type="file"> using FileReader.

SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964
  • Wow, that was straightforward. My apologies -- when investigating I thought nothing more than the name, MIME type and size could be read, but it's not the case. Thanks! – Alpha Jun 03 '14 at 00:01