1

In my angular app I have the following code:

.ts file

 download() {      
    this._fileService
        .getDownloadUrl(this.id)
        .subscribe(r => {
          window.location.href = r;
        });
 }

.html

 <span class="btn" download (click)="download()">
        <i class="fas fa-download"></i>
 </span>

For larger files it works good (like 10mb or more), the file is downloaded normally. But if the file has something like 2mb, it redirect to the link and show its content. How to avoid this and download always?

gog
  • 8,799
  • 14
  • 54
  • 104
  • 1
    Its an old link, non angular related, but you might get ideas from it: https://stackoverflow.com/questions/1066452/easiest-way-to-open-a-download-window-without-navigating-away-from-the-page – jcuypers Apr 03 '19 at 21:19

0 Answers0