Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

express-parse-multipart

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-parse-multipart

An Express.js middleware for parsing "multipart/form-data" content type

  • 1.1.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.3K
increased by6.42%
Maintainers
1
Weekly downloads
 
Created
Source

Description

Middleware parses request body with multipart/form-data content type and prepares an array of objects which represent every file which is sent in request. On the server side you will be able to get that array from req.formData property (see an example below). Every array item will contain data property which is a Buffer.

Using

  1. Make a simple Express.js server in index.js file:

    const app = require('express')();
    const parseMp = require('express-parse-multipart');
    
    app.post('/upload', parseMp, (req, res) => {
      console.log(req.formData);  // here is the target array of objects
      return res.send('Yay!');
    });
    
    app.listen(3000, () => console.log('Started on: http://localhost:3000'));
    
  2. Run it:

    node index.js
    
  3. Make a POST request using any tool you want and send any file (-s) on http://localhost:3000/upload route. Check console to see the parsed result.

Example of req.formData

[
  {
    "data": {
      "type": "Buffer",
      "data": [
        78,
        97,
        10
      ]
    },
    "name": "file1",
    "filename": "csv_test.csv",
    "type": "text/csv"
  },
  {
    "data": {
      "type": "Buffer",
      "data": [
        137,
        80,
        130
      ]
    },
    "filename": "img_test.png",
    "type": "image/png"
  },
  {
    "data": {
      "type": "Buffer",
      "data": [
        74,
        68,
        69
      ]
    },
    "name": "text1"
  }
]

Keywords

FAQs

Package last updated on 15 Aug 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc