using compressImage when serviceWorker register error

This commit is contained in:
lloydzhou
2024-07-19 16:03:22 +08:00
parent a765237441
commit 052004d70e
2 changed files with 5 additions and 0 deletions

View File

@@ -106,6 +106,10 @@ export function base64Image2Blob(base64Data: string, contentType: string) {
}
export function uploadImage(file: File): Promise<string> {
if (!window._SW_ENABLED) {
// if serviceWorker register error, using compressImage
return compressImage(file, 256 * 1024);
}
const body = new FormData();
body.append("file", file);
return fetch(UPLOAD_URL, {