snapshot of https://github.com/jitsi/jitsi-meet.git @ fd1749dd28f4138aa80234fc7f311b19aaffa0e7 (2026-09-15)
This commit is contained in:
30
react/features/file-sharing/utils.ts
Normal file
30
react/features/file-sharing/utils.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
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);
|
||||
};
|
||||
Reference in New Issue
Block a user