Pass the headers as a JSON object (e.g., event.headers). The headers must include content-type
.
Pass the multi-part form body as a string (e.g. event.body
).
async
params => {
}
const busboy = require('busboy');
const objArray = []
const bb = new busboy({ headers: params.headers });
let fileData = {}
let formData = {}
await new Promise((resolve, reject) => {
bb.on('file', function (fieldname, file, filename, encoding, mimetype) {
console.log('File [%s]: filename=%j; encoding=%j; mimetype=%j', fieldname, filename, encoding, mimetype);
fileData.file = filename
fileData.fileName = filename
fileData.encoding = encoding
fileData.mimetype = mimetype
fileData.data = {}
file
.on('data', data => {
fileData.data[fieldname] = data.length
})
}).on('field', (fieldname, val) => {
try {
formData[fieldname] = JSON.parse(val)
} catch (err) {
formData[fieldname] = val
}
})
.on("finish", resolve)
.on('error', err => { throw err })
bb.end(params.body)
})
this.file_data = fileData
this.form_data = formData
auths
objectreturn
or this.key = 'value'
, pass input data to your code viaparams
, and maintain state across executions with$checkpoint.async
(event, steps) => {
}
// to use the parsed data in workflow steps,
// refer to the exports for steps.parse_data
// e.g.,
console.log(steps.parse_data.form_data)