0

On click of a download button, I need a window that should open. User should be able to select any location for the download from the system window that pops up

This are the Request parameters I am passing to the api-

"method": "downloadCSV"

"project": "IB_SimpleProject_V2"

"dataSourceId": "DSR.4"

This is Response I am getting from it -

{ "downloadUrl": "http://localhost:8080/InBetween/...../.csv", "fileName": "<File name of csv with extension>" "message":"Download Successful", "code": 100 }

HTML:<a [href]="url" target="_blank" [download]="filename" (click)="downloadFile()">Download</a>

TS:

 downloadFile(){
    this.getDownload(project, dataSourceId).subscribe(res => {
      if (res.code === 100) {
        this.url = res.downloadUrl;
        this.filename = res.fileName;
      }
    });
  }

But I am not getting how to choose its location of download by choosing the path from the window dialog box
I am using Javascript and Angular 2+
Any help is appreciated

  • What's wrong with letting the browser handle the system side of things like choosing a save location? Besides, the app does not have direct access to the OS running the browser. – ruth Oct 09 '20 at 06:32
  • Actually, we have a customer requirement of that in which user should be allowed to choose its download location – Deeksha Mulgaonkar Oct 09 '20 at 06:43
  • 1
    It's a browser setting. Eg. in Firefox it's under _Options -> General -> Downloads -> Always ask you where to save files_. Now the browser will open the Save window for each download. – ruth Oct 09 '20 at 06:47

1 Answers1

3

You are not allowed to specifiy the download location due to security.

Helpful threads for your reference:

Specify default download folder - possibly with JavaScript?

User specified download location

huan feng
  • 7,307
  • 2
  • 32
  • 56