felid-multiparty
Multiparty plugin for Felid. Upload files without caring.
Install
npm install felid-multiparty
or
yarn add felid-multiparty
Usage
const Felid = require('felid')
const multiparty = require('felid-multiparty')
const app = new Felid()
app.plugin(multiparty, options)
app.post('/upload', async (req, res) => {
const { files } = await req.upload()
// Supposed you uploaded the file as in a field named 'file'
const file = files.file[0]
res.send({
originalFilename: file.originalFilename,
path: file.path
})
})
Options
- decorator Object: Customize the decorator names. Default is:
{
upload: 'upload'
}
API
- request.upload(options?: Object) => Promise: Handle the multipart payload. See document of multiparty for more options.