Check filename extension for heic/heif images

This commit is contained in:
Josh Perez
2021-12-06 12:20:27 -05:00
committed by GitHub
parent 69edaeabfb
commit 5c8f740c2a
3 changed files with 10 additions and 5 deletions

View File

@@ -18,7 +18,7 @@ export async function handleImageAttachment(
): Promise<InMemoryAttachmentDraftType> {
let processedFile: File | Blob = file;
if (isHeic(file.type)) {
if (isHeic(file.type, file.name)) {
const uuid = genUuid();
const bytes = new Uint8Array(await file.arrayBuffer());
@@ -41,7 +41,9 @@ export async function handleImageAttachment(
file: resizedBlob,
fileName,
} = await autoScale({
contentType: isHeic(file.type) ? IMAGE_JPEG : stringToMIMEType(file.type),
contentType: isHeic(file.type, file.name)
? IMAGE_JPEG
: stringToMIMEType(file.type),
fileName: file.name,
file: processedFile,
});