🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

@web3-storage/multipart-parser

Package Overview
Dependencies
Maintainers
5
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

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

1.0.0
latest
Source
npm
Version published
Maintainers
5
Created
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

Package last updated on 26 Jul 2021

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