如何使用Express添加MIME类型 [英] How to add MIME type with Express
本文介绍了如何使用Express添加MIME类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正试图让Firefox播放视频标签。通常,我会将其添加到Apache上的.htaccess文件中。
I'm trying to get Firefox to play a video tag. Normally, I would just add this to an .htaccess file on Apache:
AddType video/ogg .ogv
AddType video/mp4 .mp4
AddType video/webm .webm
AddType audio/mpeg .mp3
AddType audio/ogg .ogg
AddType audio/mp4 .m4a
AddType audio/wav /wav
如何使用Express / NodeJS做到这一点?
How would I do this with Express / NodeJS?
推荐答案
对于Express 4.x,可以在 https://github.com/broofa/node-mime 。
For express 4.x, good documentation on mime-type can be found in https://github.com/broofa/node-mime.
例如,Safari浏览器将显示的内容而不是下载
< a href = some.csv> ;在此处下载< / a>
。
For example, Safari browser would show the content of csv instead of downloading the csv with
<a href="some.csv">download here</a>
.
您可以通过添加以下
express.static.mime.define({'application/octet-stream': ['csv']})
这篇关于如何使用Express添加MIME类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文