content-type 文件类型列表 | Npm 包

in 前端 with 0 comment

MIME | ConentType 文件类型列表

类型一览

后缀名称文件类型
3gpvideo/3gpp
aniapplication/octet-stream
aabapplication/x-authoware-bin
aamapplication/x-authoware-map
aasapplication/x-authoware-seg
aiapplication/postscript
aifaudio/x-aiff
aifcaudio/x-aiff
aiffaudio/x-aiff
alsaudio/X-Alpha5
amcapplication/x-mpeg
asctext/plain
asdapplication/astound
asfvideo/x-ms-asf
asnapplication/astound
aspapplication/x-asap
asxvideo/x-ms-asf
auaudio/basic
avbapplication/octet-stream
avivideo/x-msvideo
awbaudio/amr-wb
bcpioapplication/x-bcpio
binapplication/octet-stream
bldapplication/bld
bld2application/bld2
bmpapplication/x-MS-bmp
bpkapplication/octet-stream
cdfapplication/x-netcdf
bz2application/x-bzip2
calimage/x-cals
ccnapplication/x-cnc
ccoapplication/x-cocoa
cgimagnus-internal/cgi
chatapplication/x-chat
classapplication/octet-stream
clpapplication/x-msclip
cmxapplication/x-cmx
coapplication/x-cult3d-object
codimage/cis-cod
cpioapplication/x-cpio
cptapplication/mac-compactpro
crdapplication/x-mscardfile
cshapplication/x-csh
csmchemical/x-csml
csmlchemical/x-csml
csstext/css
curapplication/octet-stream
dcmx-lml/x-evm
dcrapplication/x-director
dcximage/x-dcx
dhtmltext/html
dirapplication/x-director
dllapplication/octet-stream
dmgapplication/octet-stream
dmsapplication/octet-stream
docapplication/msword
dotapplication/x-dot
dviapplication/x-dvi
dwfdrawing/x-dwf
dwgapplication/x-autocad
dxfapplication/x-autocad
dxrapplication/x-director
ebkapplication/x-expandedbook
embchemical/x-embl-dl-nucleotide
emblchemical/x-embl-dl-nucleotide
epsapplication/postscript
eriimage/x-eri
esaudio/echospeech
eslaudio/echospeech
etcapplication/x-earthtime
etxtext/x-setext
evmx-lml/x-evm
evyapplication/x-envoy
exeapplication/octet-stream
fhcimage/x-freehand
fh4image/x-freehand
fh5image/x-freehand
fifimage/fif
fmapplication/x-maker
fpximage/x-fpx
fvivideo/isivideo
gauchemical/x-gaussian-input
gcaapplication/x-gca-compressed
gdbx-lml/x-gdb
gifimage/gif
gpsapplication/x-gps
gtarapplication/x-gtar
gzapplication/x-gzip
hdfapplication/x-hdf
hdmtext/x-hdml
hdmltext/x-hdml
hlpapplication/winhlp
hqxapplication/mac-binhex40
htmtext/html
htmltext/html
htstext/html
icex-conference/x-cooltalk
icoapplication/octet-stream
iefimage/ief
ifmimage/gif
ifsimage/ifs
imyaudio/melody
insapplication/x-NET-Install
ipsapplication/x-ipscript
ipxapplication/x-ipix
itaudio/x-mod
itzaudio/x-mod
ivri-world/i-vrml
j2kimage/j2k
jadtext/vnd.sun.j2me.app-descriptor
jamapplication/x-jam
jarapplication/java-archive
jnlpapplication/x-java-jnlp-file
jpeimage/jpeg
jpegimage/jpeg
jpgimage/jpeg
jpzimage/jpeg
jsapplication/x-javascript
jwcapplication/jwc
kjxapplication/x-kjx
lakx-lml/x-lak
latexapplication/x-latex
lccapplication/fastman
lclapplication/x-digitalloca
lcrapplication/x-digitalloca
lghapplication/lgh
lhaapplication/octet-stream
lmlx-lml/x-lml
lmlpackx-lml/x-lmlpack
lsfvideo/x-ms-asf
lsxvideo/x-ms-asf
lzhapplication/x-lzh
m13application/x-msmediaview
m14application/x-msmediaview
m15audio/x-mod
m3uaudio/x-mpegurl
m3urlaudio/x-mpegurl
ma1audio/ma1
ma2audio/ma2
ma3audio/ma3
ma5audio/ma5
manapplication/x-troff-man
mapmagnus-internal/imagemap
mbdapplication/mbedlet
mctapplication/x-mascot
mdbapplication/x-msaccess
mdzaudio/x-mod
meapplication/x-troff-me
meltext/x-vmel
miapplication/x-mif
midaudio/midi
midiaudio/midi
mifapplication/x-mif
milimage/x-cals
mioaudio/x-mio
mmfapplication/x-skt-lbs
mngvideo/x-mng
mnyapplication/x-msmoney
mocapplication/x-mocha
mochaapplication/x-mocha
modaudio/x-mod
mofapplication/x-yumekara
molchemical/x-mdl-molfile
mopchemical/x-mopac-input
movvideo/quicktime
movievideo/x-sgi-movie
mp2audio/x-mpeg
mp3audio/x-mpeg
mp4video/mp4
mpcapplication/vnd.mpohun.certificate
mpevideo/mpeg
mpegvideo/mpeg
mpgvideo/mpeg
mpg4video/mp4
mpgaaudio/mpeg
mpnapplication/vnd.mophun.application
mppapplication/vnd.ms-project
mpsapplication/x-mapserver
mrltext/x-mrml
mrmapplication/x-mrm
msapplication/x-troff-ms
mtsapplication/metastream
mtxapplication/metastream
mtzapplication/metastream
mzvapplication/metastream
narapplication/zip
nbmpimage/nbmp
ncapplication/x-netcdf
ndbx-lml/x-ndb
ndwnapplication/ndwn
nifapplication/x-nif
nmzapplication/x-scream
nokia-op-logoimage/vnd.nok-oplogo-color
npxapplication/x-netfpx
nsndaudio/nsnd
nvaapplication/x-neva1
odaapplication/oda
oomapplication/x-AtlasMate-Plugin
pacaudio/x-pac
paeaudio/x-epac
panapplication/x-pan
pbmimage/x-portable-bitmap
pcximage/x-pcx
pdaimage/x-pda
pdbchemical/x-pdb
pdfapplication/pdf
pfrapplication/font-tdpfr
pgmimage/x-portable-graymap
pictimage/x-pict
pmapplication/x-perl
pmdapplication/x-pmd
pngimage/png
pnmimage/x-portable-anymap
pnzimage/png
potapplication/vnd.ms-powerpoint
ppmimage/x-portable-pixmap
ppsapplication/vnd.ms-powerpoint
pptapplication/vnd.ms-powerpoint
pqfapplication/x-cprplayer
pqiapplication/cprplayer
prcapplication/x-prc
proxyapplication/x-ns-proxy-autoconfig
psapplication/postscript
ptlkapplication/listenup
pubapplication/x-mspublisher
pvxvideo/x-pv-pvx
qcpaudio/vnd.qcelp
qtvideo/quicktime
qtiimage/x-quicktime
qtifimage/x-quicktime
r3ttext/vnd.rn-realtext3d
raaudio/x-pn-realaudio
ramaudio/x-pn-realaudio
rarapplication/x-rar-compressed
rasimage/x-cmu-raster
rdfapplication/rdf+xml
rfimage/vnd.rn-realflash
rgbimage/x-rgb
rlfapplication/x-richlink
rmaudio/x-pn-realaudio
rmfaudio/x-rmf
rmmaudio/x-pn-realaudio
rmvbaudio/x-pn-realaudio
rnxapplication/vnd.rn-realplayer
roffapplication/x-troff
rpimage/vnd.rn-realpix
rpmaudio/x-pn-realaudio-plugin
rttext/vnd.rn-realtext
rtex-lml/x-gps
rtfapplication/rtf
rtgapplication/metastream
rtxtext/richtext
rvvideo/vnd.rn-realvideo
rwcapplication/x-rogerwilco
s3maudio/x-mod
s3zaudio/x-mod
scaapplication/x-supercard
scdapplication/x-msschedule
sdfapplication/e-score
seaapplication/x-stuffit
sgmtext/x-sgml
sgmltext/x-sgml
shapplication/x-sh
sharapplication/x-shar
shtmlmagnus-internal/parsed-html
shwapplication/presentations
si6image/si6
si7image/vnd.stiwap.sis
si9image/vnd.lgtwap.sis
sisapplication/vnd.symbian.install
sitapplication/x-stuffit
skdapplication/x-Koan
skmapplication/x-Koan
skpapplication/x-Koan
sktapplication/x-Koan
slcapplication/x-salsa
smdaudio/x-smd
smiapplication/smil
smilapplication/smil
smpapplication/studiom
smzaudio/x-smd
sndaudio/basic
spctext/x-speech
splapplication/futuresplash
sprapplication/x-sprite
spriteapplication/x-sprite
sptapplication/x-spt
srcapplication/x-wais-source
stkapplication/hyperstudio
stmaudio/x-mod
sv4cpioapplication/x-sv4cpio
sv4crcapplication/x-sv4crc
svfimage/vnd
svgimage/svg-xml
svhimage/svh
svrx-world/x-svr
swfapplication/x-shockwave-flash
swflapplication/x-shockwave-flash
tapplication/x-troff
tadapplication/octet-stream
talktext/x-speech
tarapplication/x-tar
tazapplication/x-tar
tbpapplication/x-timbuktu
tbtapplication/x-timbuktu
tclapplication/x-tcl
texapplication/x-tex
texiapplication/x-texinfo
texinfoapplication/x-texinfo
tgzapplication/x-tar
thmapplication/vnd.eri.thm
tifimage/tiff
tiffimage/tiff
tkiapplication/x-tkined
tkinedapplication/x-tkined
tocapplication/toc
toyimage/toy
trapplication/x-troff
trkx-lml/x-gps
trmapplication/x-msterminal
tsiaudio/tsplayer
tspapplication/dsptype
tsvtext/tab-separated-values
tsvtext/tab-separated-values
ttfapplication/octet-stream
ttzapplication/t-time
txttext/plain
ultaudio/x-mod
ustarapplication/x-ustar
uuapplication/x-uuencode
uueapplication/x-uuencode
vcdapplication/x-cdlink
vcftext/x-vcard
vdovideo/vdo
vibaudio/vib
vivvideo/vivo
vivovideo/vivo
vmdapplication/vocaltec-media-desc
vmfapplication/vocaltec-media-file
vmiapplication/x-dreamcast-vms-info
vmsapplication/x-dreamcast-vms
voxaudio/voxware
vqeaudio/x-twinvq-plugin
vqfaudio/x-twinvq
vqlaudio/x-twinvq
vrex-world/x-vream
vrmlx-world/x-vrml
vrtx-world/x-vrt
vrwx-world/x-vream
vtsworkbook/formulaone
wavaudio/x-wav
waxaudio/x-ms-wax
wbmpimage/vnd.wap.wbmp
webapplication/vnd.xara
wiimage/wavelet
wisapplication/x-InstallShield
wmvideo/x-ms-wm
wmaaudio/x-ms-wma
wmdapplication/x-ms-wmd
wmfapplication/x-msmetafile
wmltext/vnd.wap.wml
wmlcapplication/vnd.wap.wmlc
wmlstext/vnd.wap.wmlscript
wmlscapplication/vnd.wap.wmlscriptc
wmlscripttext/vnd.wap.wmlscript
wmvaudio/x-ms-wmv
wmxvideo/x-ms-wmx
wmzapplication/x-ms-wmz
wpngimage/x-up-wpng
wptx-lml/x-gps
wriapplication/x-mswrite
wrlx-world/x-vrml
wrzx-world/x-vrml
wstext/vnd.wap.wmlscript
wscapplication/vnd.wap.wmlscriptc
wvvideo/wavelet
wvxvideo/x-ms-wvx
wxlapplication/x-wxl
x-gzipapplication/x-gzip
xarapplication/vnd.xara
xbmimage/x-xbitmap
xdmapplication/x-xdma
xdmaapplication/x-xdma
xdwapplication/vnd.fujixerox.docuworks
xhtapplication/xhtml+xml
xhtmapplication/xhtml+xml
xhtmlapplication/xhtml+xml
xlaapplication/vnd.ms-excel
xlcapplication/vnd.ms-excel
xllapplication/x-excel
xlmapplication/vnd.ms-excel
xlsapplication/vnd.ms-excel
xltapplication/vnd.ms-excel
xlwapplication/vnd.ms-excel
xmaudio/x-mod
xmltext/xml
xmzaudio/x-mod
xpiapplication/x-xpinstall
xpmimage/x-xpixmap
xsittext/xml
xsltext/xml
xultext/xul
xwdimage/x-xwindowdump
xyzchemical/x-pdb
yz1application/x-yz1
zapplication/x-compress
zacapplication/x-zaurus-zac
zipapplication/zip

content-type npm - 文件类型 Npm 包

https://github.com/jshttp/content-type#readme

快速获取文件后缀名称

// 获取扩展名
const getFileExtension = filename => {
    const _filename = filename.split('.');
    return _filename[_filename.length - 1];
};

const ContentTypeMap = {
    jpeg: 'image/jpeg',
    jpg: 'image/jpeg',
    png: 'image/png',
    gif: 'image/gif',
    mp4: 'video/mpeg4',
    ppt: 'application/vnd.ms-powerpoint',
    pdf: 'application/pdf',
    txt: 'application/txt',
};

const getUploadFileContentType = file => {
    const ext = getFileExtension(file);
    const type = ContentTypeMap.ext ?: '';
    if (!type) return;

    return type;
};
Comments are closed.