blob: ecbdf47a11ea3aee317285d00881a9a4b4926d8d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
module.exports = function mimeFromExtension (file) {
const fpartz = file.split('.')
const ext = fpartz[fpartz.length-1]
let mime, type;
switch (ext.toLowerCase()) {
case 'mp3':
mime = 'audio/mp3'
type = 'audio'
break
case 'wav':
mime = 'audio/wav'
type = 'audio'
break
case 'aif':
case 'aiff':
mime = 'audio/aiff'
type = 'audio'
break
case 'm4a':
mime = 'audio/m4a'
type = 'audio'
break
case 'jpg':
case 'jpeg':
mime = 'image/jpeg'
type = 'image'
break
case 'gif':
mime = 'image/gif'
type = 'image'
break
case 'png':
mime = 'image/png'
type = 'image'
break
case 'txt':
mime = 'text/plain'
type = 'text'
break
case 'html':
mime = 'text/html'
type = 'text'
break
}
return { type, mime }
}
|