Skip to content
This repository has been archived by the owner on May 16, 2023. It is now read-only.

Use the Content-Disposition header with a filename to trigger a file download #270

Closed
darrelmiller opened this issue Mar 27, 2019 · 2 comments
Assignees
Milestone

Comments

@darrelmiller
Copy link
Contributor

When we get a response back, we should check the response headers and look for a content-disposition header. If the header contains the filename parameter then we should use that to prompt the browser to download the response to a file.

The following code may be modified to trigger the file download behavior in the browser.

function download(url, filename) {
fetch(url).then(function(t) {
    return t.blob().then((b)=>{
        var a = document.createElement("a");
        a.href = URL.createObjectURL(b);
        a.setAttribute("download", filename);
        a.click();
    }
    );
});
}
@jobala
Copy link
Contributor

jobala commented Aug 20, 2019

@cwahome what's the status of this? Should I close it?

@jobala jobala assigned ghost and unassigned thewahome-zz Aug 20, 2019
@jobala jobala modified the milestones: 1.7.12 (After Build), 1.8.x Aug 23, 2019
@ghost
Copy link

ghost commented Aug 26, 2019

Closing this as the content disposition header is unreachable unless it is sent as a preferred header from the api.

@ghost ghost closed this as completed Aug 26, 2019
@thewahome thewahome assigned thewahome and unassigned ghost Dec 17, 2019
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants