Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Save As" a file that is in HTML5 local storage in angular application

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

like image 533
dotnetgeek Avatar asked Nov 01 '22 00:11

dotnetgeek


1 Answers

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.

like image 183
Pak Avatar answered Nov 11 '22 05:11

Pak