Parse multi-part form data from JotForm webhooks
@pravin
code:
data:privatelast updated:4 years ago
today
Build integrations remarkably fast!
You're viewing a public workflow template.
Sign up to customize, add steps, modify code and more.
Join 1,000,000+ developers using the Pipedream platform
steps.
trigger
HTTP API
Deploy to generate unique URL
This workflow runs on Pipedream's servers and is triggered by HTTP / Webhook requests.
steps.
parse_data
Pass the headers and body (e.g, `event.headers` and `event.body`) for an HTTP or webhook request with multi-part form data to parse it and export it as JSON.
params
Headers

Pass the headers as a JSON object (e.g., event.headers). The headers must include content-type.

{{event.headers}}
string ·params.headers
Body

Pass the multi-part form body as a string (e.g. event.body).

{{event.body}}
string ·params.body
code
async params => {
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
}
36
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
steps.
how_to_reference_data
auth
to use OAuth tokens and API keys in code via theauths object
code
Write any Node.jscodeand use anynpm package. You can alsoexport datafor use in later steps via return or this.key = 'value', pass input data to your code viaparams, and maintain state across executions with$checkpoint.
async (event, steps) => {
1
2
3
4
5
6
}
7
// 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)