0

I need to include into my SPA application (JavaScript, AngularJS, Bootstrap) the ability to retrieve data from the server and save the data locally in CSV format.

I have the mechanism working perfectly to get the data from the server (JSON) and converting it to CSV while replacing some numerical codes to verbal values.

The only think left is to write the data AS-IS into a file (locally within the client computer).

After quite some research, I got totally confused. Some posts state that this is not possible (intentionally blocked by browsers as a security measure), others state that it can be done with Chrome, other state it is possible.

Could anyone tell me if there is a way to do it that would work with all browsers?

I should add that saving the data into a file within the Downloads folder is also a suitable option.

Thanks in advance.

FDavidov
  • 3,505
  • 6
  • 23
  • 59
  • Possible duplicate of [Create a file in memory for user to download, not through server](http://stackoverflow.com/questions/3665115/create-a-file-in-memory-for-user-to-download-not-through-server) – Walfrat May 04 '16 at 09:34
  • I don't think this is a duplicate @Walfrat since, after trying the solution presented there, it would appear that it only works with Chrome (it does not with Edge nor with IE). – FDavidov May 04 '16 at 11:02
  • Have you tryed the solution describe in the answer below the accepted answer ? It says it's working for every HTML5 browser. And the next answer talk about a fileSaver library. Considering that it's not possible to acces the hard drive from Javascript, the only way is to do as describe in the answers of this post. – Walfrat May 04 '16 at 11:17

1 Answers1

0

I d'ont know if you manage big data, but another solution can be to put your data into local storage of browser.

I think it's hard to write a file into client disk from javascript code.

Silvinus
  • 1,445
  • 8
  • 16
  • Thank you @Silvinus. No, I don't manage BIG DATA. If I would need to guess the maximal size of such a file, it would be few MB (definitely less than 10MB). Can you suggest (and, if possible, give an example) any methods I can use to create a file locally? I can consider the option of DOWNLOADING, but this might create too much load at the server side (and hence my desire to handle the manipulations at the client's side). – FDavidov May 04 '16 at 11:03