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

formstream

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

formstream

A multipart/form-data encoded stream, helper for file upload.

1.5.1
latest
Version published
Weekly downloads
182K
-2.8%
Maintainers
2
Weekly downloads
 
Created

What is formstream?

The formstream npm package is used to create multipart/form-data streams, which are useful for uploading files and data via HTTP requests. It simplifies the process of constructing form data streams, making it easier to handle file uploads in Node.js applications.

What are formstream's main functionalities?

Create a form stream

This feature allows you to create a form stream, add fields and files to it, and then generate the stream for use in an HTTP request.

const formstream = require('formstream');
const form = formstream();
form.field('name', 'value');
form.file('file', '/path/to/file');
form.stream();

Add fields to the form

This feature allows you to add text fields to the form stream. Each field is added with a key-value pair.

const form = formstream();
form.field('username', 'john_doe');
form.field('email', 'john@example.com');

Add files to the form

This feature allows you to add files to the form stream. Each file is added with a key and the file path.

const form = formstream();
form.file('profile_picture', '/path/to/profile.jpg');

Generate the form stream

This feature generates the form stream after adding all the fields and files. The generated stream can then be used in an HTTP request.

const form = formstream();
form.field('username', 'john_doe');
form.file('profile_picture', '/path/to/profile.jpg');
const stream = form.stream();

Other packages similar to formstream

FAQs

Package last updated on 07 Jun 2024

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