Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -223,22 +223,24 @@ async function makeRequest(
}

if (fileExtension) {
return response.blob().then((blob: any) => {
return response.blob().then((blob: Blob) => {
const url = window.URL.createObjectURL(blob);

const link = document.createElement("a");
link.href = url;
// Now the file name includes the extension
link.setAttribute("download", `file${fileExtension}`);

// These two lines are necessary to make the link click in Firefox
link.style.display = "none";
document.body.appendChild(link);
// These lines are necessary to make the link click in Firefox
const hiddenContainer = document.createElement("div");
hiddenContainer.style.display = "none";
hiddenContainer.appendChild(link);
document.body.appendChild(hiddenContainer);

link.click();

// After link is clicked, it's safe to remove it.
setTimeout(() => document.body.removeChild(link), 0);
setTimeout(() => document.body.removeChild(hiddenContainer), 0);

return response;
});
Expand Down
Loading