1 |
|
2 |
|
3 |
|
4 |
|
5 | const mimeToExtensions = {
|
6 | 'audio/mp3': 'mp3',
|
7 | 'audio/ogg': 'ogg',
|
8 | 'audio/webm': 'webm',
|
9 | 'image/gif': 'gif',
|
10 | 'image/heic': 'heic',
|
11 | 'image/heif': 'heif',
|
12 | 'image/jpeg': 'jpg',
|
13 | 'image/png': 'png',
|
14 | 'image/svg+xml': 'svg',
|
15 | 'video/mp4': 'mp4',
|
16 | 'video/ogg': 'ogv',
|
17 | 'video/quicktime': 'mov',
|
18 | 'video/webm': 'webm',
|
19 | 'video/x-matroska': 'mkv',
|
20 | 'video/x-msvideo': 'avi'
|
21 | }
|
22 |
|
23 | module.exports = function getFileTypeExtension (mimeType) {
|
24 |
|
25 | mimeType = mimeType.replace(/;.*$/, '')
|
26 | return mimeToExtensions[mimeType] || null
|
27 | }
|