2

I'm developing a web application that can be used offline. Among other features it should be able to save a binary file with user created data to the device. In particular, on iPad it should allow to download the file and get an "Open In..." dialog, e.g. to save the file to Dropbox. Possible browsers are Safari and Chrome (on iPad). How to do that from JavaScript?

This question - Using HTML5/Javascript to generate and save a file - provides a number of recipes. I've tried this - https://stackoverflow.com/a/19230609/404099 - and it allowed to open a text file in another tab. Alas - no way to save to Dropbox and didn't work with a binary file.

The https://github.com/eligrey/FileSaver.js library works the same. Text files are opened in another tab, binary files doesn't work. E.g.:

var blob = new Blob(["Hello, world!"], {type: "application/octet-stream"});
saveAs(blob, "hello-world.dat");
Community
  • 1
  • 1
Ilia Barahovsky
  • 10,158
  • 8
  • 41
  • 52

1 Answers1

0

Since this question got some attention and no answer, I want to share a partial answer, which is what I ended up doing. I haven't found a way to trigger "Open in..." dialog for binary files. So my solution was to use Dropbox API directly to save the file to the Dropbox account of the user. The working architecture is:

  • Web site with application caching for offline usage (the standard is deprecated)
  • Web SQL for local data storage (the standard is deprecated)
  • Dropbox API for saving data files aside and following usage in other apps. Any other cloud storage solution can be used here.
Ilia Barahovsky
  • 10,158
  • 8
  • 41
  • 52