Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

File Save functionality in Angular

I am looking for file saving ( in my local file system) functionality in Angular. I already gone through following modules.

Angular-file-saver

But it asked for confirmation before saving file.

I want my file to saved automatically in my local folder ( C:\MyApplication\contents)

FileSaver.saveAs(new Blob([data], { type: "video/mp4" }), 'C:\MyApplication\contents\myvideo.mp4');

Any pointers would be really helpful.

like image 523
dip Avatar asked Jan 29 '23 18:01

dip


1 Answers

I think the best way is to handle it yourself.

Create a blob from your data.

myBlob = new Blob([new Uint8Array(myData)], {type: "octet/stream"});

Now create <a> element in the memory and click on it.

var link = document.createElement('a');
link.href = window.URL.createObjectURL(myBlob);;
link.click(); 
like image 60
Charlie Avatar answered Jan 31 '23 07:01

Charlie