From 34ea6b28214d15c7c47185dba486b61702fa718e Mon Sep 17 00:00:00 2001 From: Pratyush <155612188+itz-Me-Pj@users.noreply.github.com> Date: Wed, 12 Nov 2025 18:12:29 +0530 Subject: [PATCH] =?UTF-8?q?Added=20Image=20check=20for=20Allowed=20Image?= =?UTF-8?q?=20Extentions=20to=20categorize=20raw=20came=E2=80=A6=20(#9241)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Added Image check for Allowed Image Extentions to categorize raw camera formats as attachments * Incorporated Copilot suggestion for constant and resuable method also updated method to satify test cases --- app/utils/file/index.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/app/utils/file/index.ts b/app/utils/file/index.ts index 65c74d9fa..2126ae474 100644 --- a/app/utils/file/index.ts +++ b/app/utils/file/index.ts @@ -66,6 +66,8 @@ const SUPPORTED_DOCS_FORMAT = Platform.select({ ], }); +const SUPPORTED_IMAGE_FORMAT = ['png', 'jpg', 'jpeg', 'bmp', 'tiff', 'svg', 'xcf', 'gif']; + const SUPPORTED_VIDEO_FORMAT = Platform.select({ ios: ['video/mp4', 'video/x-m4v', 'video/quicktime'], android: ['video/3gpp', 'video/x-matroska', 'video/mp4', 'video/webm', 'video/quicktime'], @@ -266,6 +268,11 @@ export const isGif = (file?: FileInfo | FileModel) => { return mime === 'image/gif'; }; +export function extractExtension(filename: string) { + const ext = filename.split('.').pop() || ''; + return ext.startsWith('.') ? ext.slice(1).toLowerCase() : ext.toLowerCase(); +} + export const isImage = (file?: FileInfo | FileModel) => { if (!file) { return false; @@ -275,6 +282,12 @@ export const isImage = (file?: FileInfo | FileModel) => { return true; } + const fileExt = extractExtension(file.extension || file.name); + + if (!SUPPORTED_IMAGE_FORMAT.includes(fileExt)) { + return false; + } + let mimeType = 'mime_type' in file ? file.mime_type : file.mimeType; if (!mimeType) { mimeType = lookupMimeType(file.extension) || lookupMimeType(file.name);