Skip to content

Instantly share code, notes, and snippets.

@hosseinmh
Forked from javilobo8/download-file.js
Created November 3, 2020 15:13
Show Gist options
  • Select an option

  • Save hosseinmh/6f46bdbb70da026277db39b5429c0dd5 to your computer and use it in GitHub Desktop.

Select an option

Save hosseinmh/6f46bdbb70da026277db39b5429c0dd5 to your computer and use it in GitHub Desktop.

Revisions

  1. @javilobo8 javilobo8 revised this gist May 11, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion download-file.js
    Original file line number Diff line number Diff line change
    @@ -3,7 +3,7 @@ axios({
    method: 'GET',
    responseType: 'blob', // important
    }).then((response) => {
    const url = window.URL.createObjectURL(new Blob([data]));
    const url = window.URL.createObjectURL(new Blob([response.data]));
    const link = document.createElement('a');
    link.href = url;
    link.setAttribute('download', 'file.pdf');
  2. @javilobo8 javilobo8 created this gist May 11, 2017.
    12 changes: 12 additions & 0 deletions download-file.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    axios({
    url: 'http://localhost:5000/static/example.pdf',
    method: 'GET',
    responseType: 'blob', // important
    }).then((response) => {
    const url = window.URL.createObjectURL(new Blob([data]));
    const link = document.createElement('a');
    link.href = url;
    link.setAttribute('download', 'file.pdf');
    document.body.appendChild(link);
    link.click();
    });