Added Image check for Allowed Image Extentions to categorize raw came… (#9241)

* 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
This commit is contained in:
Pratyush 2025-11-12 18:12:29 +05:30 committed by GitHub
parent 4a2cad681d
commit 34ea6b2821
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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);