azure-func-multipart-parser

0.1.10 • Public • Published

azure-func-multipart-parser

Build Status

Multipart form parser for Azure Functions JS 2.0.

Azure Functions JS 2.0 do not support streams and using libraries like multiparty or multer may not be easy. So you can use this simple parser.

Note: Do not use multipart forms with big files in Azure Functions JS 2.0.

Install

npm install azure-func-multipart-parser --save

Usage

function.json

{
  "bindings": [
    {
      "name": "req",
      "type": "httpTrigger",
      "direction": "in",
      "dataType": "binary"
    }
  ]
}

index.js

const { parse } = require('azure-func-multipart-parser');
 
module.exports = async (ctx) => {
  const { fields, files } = parse(ctx.req);
  // ...
};

See examples.

API

Table of Contents

parser

Type: Object

isMultipartForm

Checks if it is a request with multipart form

Parameters
  • headers Object The object of headers (request.headers)

Returns boolean

getBoundary

Get a boundary from request headers

Parameters
  • headers Object The object of headers (request.headers)

Returns string

parseBody

Parse a body with multipart form

Parameters
  • body (string | Buffer) The request body (request.body)
  • boundary string The multipart form boundary

Returns resultOfParsing

parse

Parse a multipart form

Parameters
  • request Object The request object

Returns resultOfParsing

resultOfParsing

Type: Object

Properties

  • fields Object<sting, sting>
  • files Object<sting, fileObject>

fileObject

Type: Object

Properties
  • filename string The file name
  • type string The content type
  • charset string The charset
  • encoding string The transfer encoding
  • content Buffer The file content

Readme

Keywords

none

Package Sidebar

Install

npm i azure-func-multipart-parser

Weekly Downloads

236

Version

0.1.10

License

ISC

Unpacked Size

139 kB

Total Files

27

Last publish

Collaborators

  • safer-bwd