fix: upload .heic image

This commit is contained in:
Shansing 2024-06-08 21:51:56 +08:00
parent 5136c14a4d
commit 9ebdb3239a

View File

@ -39,7 +39,10 @@ export function compressImage(file: File, maxSize: number): Promise<string> {
};
reader.onerror = reject;
if (file.type.includes("heic")) {
if (
file.name.toLowerCase().endsWith(".heic") ||
file.type.includes("heic")
) {
heic2any({ blob: file, toType: "image/jpeg" })
.then((blob) => {
reader.readAsDataURL(blob as Blob);
@ -47,8 +50,8 @@ export function compressImage(file: File, maxSize: number): Promise<string> {
.catch((e) => {
reject(e);
});
} else {
reader.readAsDataURL(file);
}
reader.readAsDataURL(file);
});
}