mirror of
https://gitcode.com/GitHub_Trending/ji/jitsi-meet.git
synced 2026-05-14 15:27:49 +00:00
* Update version, suppress build errors without adding Firebase related dependencies and raise the app bundle limit. --------- Co-authored-by: Yash <139779840+yashop7@users.noreply.github.com>
31 lines
701 B
TypeScript
31 lines
701 B
TypeScript
const generateDownloadUrl = async (url: string) => {
|
|
const resp = await fetch(url);
|
|
const respBlob = await resp.blob();
|
|
|
|
const blob = new Blob([ respBlob ]);
|
|
|
|
// @ts-ignore
|
|
return URL.createObjectURL(blob);
|
|
};
|
|
|
|
export const downloadFile = async (url: string, fileName: string) => {
|
|
const dowloadUrl = await generateDownloadUrl(url);
|
|
const link = document.createElement('a');
|
|
|
|
if (fileName) {
|
|
link.download = fileName;
|
|
}
|
|
link.href = dowloadUrl;
|
|
|
|
document.body.appendChild(link);
|
|
link.click();
|
|
link.remove();
|
|
|
|
// fix for certain browsers
|
|
setTimeout(() => {
|
|
|
|
// @ts-ignore
|
|
URL.revokeObjectURL(dowloadUrl);
|
|
}, 0);
|
|
};
|