Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Node.js - generate multipart/form-data

Is there a Node.js library for generating multipart/form-data content in the following form?

------------------------------7a9cd2dc11c1
Content-Disposition: form-data; name="to"

[email protected]
------------------------------7a9cd2dc11c1
Content-Disposition: form-data; name="from"

[email protected]
------------------------------7a9cd2dc11c1
Content-Disposition: form-data; name="subject"

subject line
------------------------------7a9cd2dc11c1
Content-Disposition: form-data; name="text"

This content does not matter.
------------------------------7a9cd2dc11c1--
like image 380
exupero Avatar asked Oct 30 '11 15:10

exupero


People also ask

How do I get node js form data?

To get started with forms, we will first install the body-parser(for parsing JSON and url-encoded data) and multer(for parsing multipart/form data) middleware. var express = require('express'); var bodyParser = require('body-parser'); var multer = require('multer'); var upload = multer(); var app = express(); app.

What is busboy in node JS?

Busboy is an event-based streaming parser that's not tied to Express. js. Instead of storing intermediate files, it provides a stream to the incoming file. It's been around since 2013. The core multipart/form-data implementation has been extracted to a separate dicer module.

What is Multiparty in node JS?

Parse http requests with content-type multipart/form-data , also known as file uploads. See also busboy - a faster alternative which may be worth looking into.


1 Answers

fermata looks like it might be what you're looking for. From the github page:

fermata.json("http://example.com/some/action").post({
  'Content-Type':"multipart/form-data"
}, {
  fileField: form.input.file || {data:nodeBuffer, name:"", type:""}
}, callback)
like image 160
thejh Avatar answered Sep 24 '22 03:09

thejh