How could I upload files in ExpressJS 4.x

前端 未结 3 606
野的像风
野的像风 2020-12-16 02:33

I know there are something like multiparty, and busboy and formidable. I want to know is there any chance to upload files without them.

3条回答
  •  不知归路
    2020-12-16 02:57

    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:

    Direct parsing (in descending popularity based on Github stars as of Nov 2016):

    • formidable
    • busboy
    • multiparty

    Middleware:

    • 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

    Both:

    • 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

    Happy coding.

提交回复
热议问题