file download is added

This commit is contained in:
병준 박 2019-11-07 18:28:13 +09:00
parent a7dbb1f545
commit 9417b757da

View File

@ -56,6 +56,19 @@ export class FileUtil {
}); });
} }
static downloadFromBlob(blob: Blob, fileName: string) {
const a = document.createElement('a');
document.body.appendChild(a);
a.style.display = 'none';
const url = URL.createObjectURL(blob);
a.href = url;
a.download = fileName;
a.click();
window.URL.revokeObjectURL(url);
a.remove();
}
static thumbnail(file: File): Promise<File> { static thumbnail(file: File): Promise<File> {
return new Promise<File>((resolve, reject) => { return new Promise<File>((resolve, reject) => {
const fileReader = new FileReader(); const fileReader = new FileReader();