Socket
Book a DemoInstallSign in
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

latest
Source
npmnpm
Version
1.0.0
Version published
Weekly downloads
599K
-8.75%
Maintainers
5
Weekly downloads
 
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