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:
parent
4a2cad681d
commit
34ea6b2821
1 changed files with 13 additions and 0 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in a new issue