This commit is contained in:
azizziy
2025-05-20 17:02:10 +05:00
commit c01e852a59
257 changed files with 27766 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
class FileService {
download(file: File, name?: string) {
const link = document.createElement('a');
const fileUrl = URL.createObjectURL(file);
link.download = name || file.name;
link.href = fileUrl;
link.click();
URL.revokeObjectURL(fileUrl);
}
downloadByDisposition(disposition: string, blob: Blob) {
const fileUrl = URL.createObjectURL(blob);
const contentDisposition = disposition;
const filename = contentDisposition.split('filename=')[1] as string;
const downloadFileName = filename.slice(1, filename.length - 1);
const link = document.createElement('a');
link.download = downloadFileName;
link.href = fileUrl;
link.click();
URL.revokeObjectURL(fileUrl);
}
}
export const file_service = new FileService();