mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-09 03:21:23 +00:00
- fixed by giving a proper filename. - not fixed: filename exists, but is untitled, need to wait for backend update to get a proper title Co-authored-by: wil <wil@storyteller.ai>
30 lines
657 B
TypeScript
30 lines
657 B
TypeScript
import { AddToast, ToastTypes } from "~/contexts/ToasterContext";
|
|
|
|
export const downloadFile = ({
|
|
url,
|
|
addToast,
|
|
title,
|
|
}:{
|
|
url: string,
|
|
addToast: AddToast,
|
|
title: string
|
|
}) => {
|
|
console.log(url);
|
|
fetch(url)
|
|
.then((resp) => resp.blob())
|
|
.then((blob) => {
|
|
const blobUrl = window.URL.createObjectURL(blob);
|
|
const a = document.createElement("a");
|
|
a.style.display = "none";
|
|
a.href = blobUrl;
|
|
a.download = `${title}.mp4`;
|
|
document.body.appendChild(a);
|
|
a.click();
|
|
window.URL.revokeObjectURL(url);
|
|
})
|
|
.catch(() => addToast(ToastTypes.ERROR, "Could not download file."));
|
|
};
|
|
|
|
//check
|
|
|