Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

request-multipart

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

request-multipart

Multipart Body Stream

  • 0.0.1
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

request-multipart

npm-version travis-ci coveralls-status

multipart/form-data and multipart/related support for request-compose

var compose = require('request-compose')
compose.Request.multipart = require('request-multipart')
var fs = require('fs')

;(async () => {
  try {
    var {body} = await compose.client({
      method: 'POST',
      url: 'https://slack.com/api/files.upload',
      qs: {title: 'My Awesome Cat!'},
      headers: {authorization: 'Bearer [ACCESS TOKEN]'},
      multipart: {file: fs.readFileSync('cat.png')}
    })
    console.log(body)
  }
  catch (err) {
    console.error(err)
  }
})()

Table of Contents

multipart/form-data

value can be String, Buffer or Stream

multipart: {
  key: 'value'
}
multipart: {
  key: [
    'value',
    'value',
  ]
}
multipart: {
  key: {
    value: 'value',
    options: {filename: '', contentType: '', knownLength: 0}
  }
}

multipart/related

body can be String, Buffer or Stream

multipart: [
  {key: 'value', body: 'body'},
  {key: 'value', body: 'body'},
]

Internal API

var options = {
  // related
  multipart: [],
  // form-data
  multipart: {},

  // optional
  contentType: 'multipart/related; boundary=',
  boundary: '',
  preambleCRLF: true,
  postambleCRLF: true
}


var {contentType, body} = multipart(options)

Keywords

FAQs

Package last updated on 01 May 2018

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc