0
 <a href="{{attachment.attachmentLocation}}" target="_blank" download>
{{attachment.fileName}} ({{ attachment.attachmentDate | date:'YYYY-MM-DD'}})</a>

I have tried to download by converting it to a blob file but its downloads the corrupt file.

In anchor tag href i get a path like "C://assets/attachments/test.jpg". But when i click on the link it just opens in a new tab but doesnt get downloaded. Is there any way to download any type of file type from href?

Thanks for help in advance.

Gaurav Shrestha
  • 151
  • 1
  • 10

1 Answers1

0

You either need a Content-Disposition: attachment; in your HTTP headers to make the browser treat the file as download or you can create attach a blob to the link (see this answer)

Georgi Georgiev
  • 3,854
  • 5
  • 29
  • 39
  • I just wanted to download it by clicking the anchor tag and I wanted to download any type of file type. – Gaurav Shrestha Jan 10 '19 at 07:36
  • Blobs work for any type of file. But you can't do this without javascript. See the linked answer you can add a click handler to the link and create the blob there. – Georgi Georgiev Jan 10 '19 at 07:38
  • how can i create my link to text, name, type. Sorry for the trouble. i get a link like "../asssets/attachments/test.jpg" – Gaurav Shrestha Jan 10 '19 at 08:22