Socket
Socket
Sign inDemoInstall

@web3-storage/multipart-parser

Package Overview
Dependencies
0
Maintainers
5
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @web3-storage/multipart-parser

A simple multipart/form-data parser to use with ReadableStreams


Version published
Weekly downloads
419K
increased by4.23%
Maintainers
5
Install size
52.7 kB
Created
Weekly downloads
 

Readme

Source

multipart-parser

A simple multipart/form-data parser to use with ReadableStreams

Based on https://github.com/ssttevee/js-multipart-parser

Install

# install it as a dependency
$ npm i @web3-storage/multipart-parser

Usage

import { parseMultipart } from '@web3-storage/multipart-parser';

...

async function requestHandler(req) {
    const boundary = '----whatever';
    const parts = await parseMultipart(req.body, boundary);
    const fd = new FormData();
    for (const { name, data, filename, contentType } of parts) {
        if (filename) {
            fd.append(name, new Blob([data], { type: contentType }), filename);
        } else {
            fd.append(name, new TextDecoder().decode(data), filename);
        }
    }
}

Releasing

You can publish by either running npm publish in the dist directory or using npx ipjs publish.

FAQs

Last updated on 26 Jul 2021

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc