How to download a URL file into a specific directory in a project in angular?

1.2k views Asked by At

I am getting file URL in an API response. The URL is downloadable, if I hit it into browser then the file will be download into the system's Download folder.

But I want to download this file into a specific folder in the project. Does it possible.

My download code is as below:

downloadFile(url, i){
 if(i==0 || i==1){
   let file = new Blob([url], { type: 'html;charset=utf-8' });
   saveAs(url, 'outputfile.html')
 }else if(i==2){
   let file = new Blob([url], { type: 'zip;charset=utf-8' });
   saveAs(url, 'outputfile.zip')
 }else if(i==3){
   let file = new Blob([url], { type: 'text;charset=utf-8' });
   saveAs(url, 'outputfile.txt')
 }

}

1

There are 1 answers

1
Tolui Davaasuren On

You cannot download file into frontend project instead you can upload that file to your backend server