如何在ExpressJS 4.x中上传文件? [英] How could I upload files in ExpressJS 4.x
本文介绍了如何在ExpressJS 4.x中上传文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道有一些类似 multiparty
和 busboy
并且强大。我想知道有没有机会上传文件。
I know there are something like multiparty
, and busboy
and formidable. I want to know is there any chance to upload files without them.
推荐答案
如果要上传文件,您需要能够解析多部分内容。您可以使用它来解析它或实现自己的。以下是可以帮助您的模块的列表:
If you want to upload files you need to be able to parse multipart content. You can either use to parse it or implement your own. Here's a list the modules that can help you:
直接解析(截至2016年11月,基于Github星的人气降低):
Direct parsing (in descending popularity based on Github stars as of Nov 2016):
- formidable
- busboy
- multiparty
中间件:
- multer < a> - 基于busboy,比以下选项更受欢迎
- busboy中间件 - 最后一次提交2014年4月
- 多方中间件 - 建议不要在Github页面上使用
- multer - based on busboy, much more popular than options below
- busboy middleware - last commit April 2014
- multiparty middleware - suggests not to use on Github page
两者:
- parted - last commit Jan 2015
- parted - last commit Jan 2015
如果你想编写自己的解析器,你可以看看模块上面是怎么做到的。检查这些链接:
If you want to write your own parser, you can have a look how above modules does it. Check these links also:
- Here's how it looks like
- multipart protocol spec and html spec
- Blog post about implementing formidable
- bop: Boyer Moore Parser, good node module to find the multipart boundaries position
- Another blog post about implementing multi-part parser
快乐编码。
这篇关于如何在ExpressJS 4.x中上传文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文