Compress answers and show upload progress

This commit is contained in:
2025-09-14 17:45:34 +02:00
parent b6b43618a7
commit 5c66430cb4
6 changed files with 93 additions and 16 deletions
+21
View File
@@ -1 +1,22 @@
import Compressor from 'compressorjs';
export const createImageURL = (file: File) => URL.createObjectURL(file);
export async function compressImage(file: File) {
return new Promise<File | Blob>((resolve, reject) => {
if (!file) {
reject();
return;
}
new Compressor(file, {
quality: 0.8,
error(error) {
console.error(error);
reject(error);
},
success(result) {
resolve(result);
}
});
}).catch(() => file);
}