0

My problem is simple (I hope) but not too well documented (or I am a bad researcher).

I am developing a web service using angular and slickgrid.

The user can visualize the data in the grid filtered in any way they want, and I, in the controller, can get this data as an array of json objects with simply $scope.grid.getData

What the user needs now is a "save as" button that allows them to save this data they can see in the grid (which I can process in the controller side to turn into something like an excel file or a csv).

All the information I am finding is about saving resources from a remote server (hence using a link or something similar), and let the browser display the "save as" dialog. The resource I want the user to be able to save is already in their local machine, as a temporary array that fills the grid they are visualizing.

What would I need in the html and controller, using angular, to do this in a smart way?

I hope it's an easy one for an angular guru :)

Thank you in advance!

I will restate my question: is there a way to save certain file created by a web-app on the client hard drive?

I can see there are amazing possibilities for data storage in HTML5 nowadays: a browser can store 5M of data (or even more), it can store it for one session, or forever... so: is it really THAT difficult let the user save a file, a string, a cvs, a json... ANY of this stored information in their system, in a folder in their hard drive, if they want to? :)

I don't know anymore if this problem is so difficult that one can not find examples on how to do this online or if it is so easy that nobody thinks anybody will need an example on how to do it and that's the reason why one can not find them :)

Cristina
  • 21
  • 6
  • Read this: http://stackoverflow.com/questions/5082404/saving-file-from-javascript-string-without-hitting-server It is possible using data uris - but the traditional approach is to bounce the data off the server. (It is kind of scary to think javascript could write/modify files on the local system, which is why this can be a tricky problem.) – aet May 08 '14 at 17:06
  • Thanks a lot for your fast reply :) – Cristina May 09 '14 at 07:29
  • The data I would like the user to be able to save is in the local system, but it is the content of a variable of the javascript code itself, this is: it does not really "belong" to the user. In my case, I am using slickgrid because it can manage very fast to filter thousands of records ( http://mleibman.github.io/SlickGrid/examples/example-optimizing-dataview.html ). The time it takes to bring all this data from the server to the client is the critical issue. I'm sure the link you have given to me will help me to find a way tho :) – Cristina May 09 '14 at 07:38
  • Note that the data URIs method has limits in the size of data that can be stored/downloaded (it is browser specific and nobody knows the exact size allowed by each browser/version, but there is a limit). – gkalpak May 09 '14 at 13:58
  • If you know the user's browser will support the new HTML5 FileSystem API, this article might be useful: http://www.noupe.com/webdev/html5-filesystem-api-create-files-store-locally-using-javascript-webkit.html – gkalpak May 09 '14 at 14:19
  • Thank you very much ExpertSystem. That's a very interesting article and it is closest than anything I've been able to find to what I am trying to do :) – Cristina May 12 '14 at 07:38

0 Answers0