azure-func-multipart-parser
v0.1.10
Published
Multipart form parser for Azure Functions JS
Downloads
720
Readme
azure-func-multipart-parser
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
Returns resultOfParsing
parse
Parse a multipart form
Parameters
request
Object The request object
Returns resultOfParsing
resultOfParsing
Type: Object
Properties
fileObject
Type: Object