Skip to content

Commit 2b1ab97

Browse files
authored
[CLNP-5230] Support .bmp and .heic (#1235)
### Changelog * Support `.bmp` and `.heic` to be rendered properly in `MessageBody`. * `.bmp` file will rendered as `ThumbnailMessage`. `.heic` file will be rendered as regular `FileMessage`, for consistency between browsers.
1 parent 258d735 commit 2b1ab97

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { FileMessage } from '@sendbird/chat/message';
2+
import { isThumbnailMessage } from '../index';
3+
4+
const mockBmpFileMessage = {
5+
message: null,
6+
messageType: 'file',
7+
createdAt: 1,
8+
type: 'image/bmp',
9+
name: 'test_image.bmp',
10+
file: new File([], 'test_image.bmp'),
11+
metaArrays: [
12+
{ key: 'KEY_INTERNAL_MESSAGE_TYPE', value: ['image/bmp'] },
13+
],
14+
} as unknown as FileMessage;
15+
16+
const mockHeicFileMessage = {
17+
message: null,
18+
messageType: 'file',
19+
createdAt: 1,
20+
type: 'image/heic',
21+
name: 'test_image.heic',
22+
file: new File([], 'test_image.heic'),
23+
metaArrays: [
24+
{ key: 'KEY_INTERNAL_MESSAGE_TYPE', value: ['image/heic'] },
25+
],
26+
} as unknown as FileMessage;
27+
28+
describe('Global-utils/isThumbnailMessage', () => {
29+
30+
it('should return ture for .bmp extension', () => {
31+
expect(isThumbnailMessage(mockBmpFileMessage)).toBe(true);
32+
});
33+
34+
it('should return false for .heic extension', () => {
35+
expect(isThumbnailMessage(mockHeicFileMessage)).toBe(false);
36+
});
37+
38+
});

src/utils/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export const SUPPORTED_MIMES = {
3030
'image/gif',
3131
'image/svg+xml',
3232
'image/webp', // not supported in IE
33+
'image/bmp',
3334
],
3435
VIDEO: [
3536
'video/mpeg',
@@ -115,7 +116,7 @@ export const SUPPORTED_MIMES = {
115116
};
116117

117118
export const SUPPORTED_FILE_EXTENSIONS = {
118-
IMAGE: ['.apng', '.avif', '.gif', '.jpg', '.jpeg', '.jfif', '.pjpeg', '.pjp', '.png', '.svg', '.webp', '.bmp', '.ico', '.cur', '.tif', '.tiff'],
119+
IMAGE: ['.apng', '.avif', '.gif', '.jpg', '.jpeg', '.jfif', '.pjpeg', '.pjp', '.png', '.svg', '.webp', '.bmp', '.ico', '.cur', '.tif', '.tiff', '.heic', '.heif'],
119120
VIDEO: ['.mp4', '.webm', '.ogv', '.3gp', '.3g2', '.avi', '.mov', '.wmv', '.mpg', '.mpeg', '.m4v', '.mkv'],
120121
AUDIO: ['.aac', '.midi', '.mp3', '.oga', '.opus', '.wav', '.weba', '.3gp', '.3g2'],
121122
DOCUMENT: ['.txt', '.log', '.csv', '.rtf', '.pdf', '.doc', '.docx', '.xls', '.xlsx', '.ppt', '.pptx'],

0 commit comments

Comments
 (0)