5

I have seen a number of questions that talk about getting data into HTML5 local storage and even seen a cool text editor that saves the files in local storage. I have a similar application and would like to now be able to let a user take a file they have been editing in local storage and then save it on their desktop.

I can stream the file up to a service on the server and get the browser to prompt that way but I was hoping to keep it all client side. The files are typically going to be text or xml based. Is there a way to setup a service in angular to take the bytes of the file in local storage then stream that and make the browser prompt the user for the save location etc.

Any help keeping it client side would be greatly appreciated.

Rich

3
  • The way to do it is to send the file to a server and then have the user download it. I don't think there's a way to save it from local storage to hard disk, client side. Commented May 1, 2014 at 19:14
  • 1
    @EliteOctagon You can using blobs. html5rocks.com/en/tutorials/file/filesystem Commented May 1, 2014 at 19:18
  • 1
    The main question is "How to save a java script object in file?" because we can easily read and write java script objects from local storage: There are some answers to them which I haven't personally tried but this seems promising: muaz-khan.blogspot.com/2012/10/… Commented May 1, 2014 at 20:18

1 Answer 1

2

You don't need to upload the file to a server and let the user donwload it - it makes no sense. What if the server shouldn't be allowed to access this file?

Anyway, I use the FileSaver.js library in my angularJS projects and it works just fine.

You can serve several files in a file archive with libraries such as JSZip.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.