Save Zoom recordings to Amazon S3, then delete Zoom recording
@dylburger
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
steps.
construct_filename_and_download_url
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
8
9
}
10
const shortid = require('shortid')

// A recording with a topic "Test Recording" and file type MP4 becomes "test_recording-abc123.mp4"
// We append a "short ID" to avoid collisions for recordigs with the same topic name
const meetingTopic = event.meeting_topic.replace(/[^a-zA-Z0-9]/g, '_').toLowerCase()
this.filename = `${meetingTopic}-${shortid.generate()}.${event.file_type.toLowerCase()}`

this.downloadURL = `${event.download_url}?access_token=${event.download_token}`
steps.
upload_recording_to_amazon_s3
auth
to use OAuth tokens and API keys in code via theauths object
(auths.aws)
params
Bucket
 
string ·params.Bucket
Download URL

The URL of the file to upload to S3

{{steps.construct_filename_and_download_url.downloadURL}}
string ·params.downloadURL
Filename
{{steps.construct_filename_and_download_url.filename}}
string ·params.filename
AWS Region

The AWS region tied to your S3 bucket, e.g us-east-1 or us-west-2

 
us-east-1
string ·params.region
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, params, auths) => {
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
const AWS = require("aws-sdk")
const fetch = require('node-fetch');
const format = require('date-fns/format')

const { accessKeyId, secretAccessKey } = auths.aws
const { Bucket, downloadURL, filename, region } = params

const s3 = new AWS.S3({
  accessKeyId,
  secretAccessKey,
  region,
})

// Stream the data from HTTP request directly to S3.
// AWS' s3.upload method below accepts a Readable stream
// as the Body, which fetch returns by default.
// See https://github.com/aws/aws-sdk-js/issues/2100
const recordingResponse = await fetch(downloadURL)

this.s3Response = await s3.upload({
  Bucket,
  Key: `${format(new Date(), "yyyy/MM/dd/")}${filename}`, // Store in YYYY/MM/DD/ "dirs" to avoid name collisions
  Body: recordingResponse.body,
}).promise()
steps.
zoom_delete_recording
Deletes a Zoom cloud recording
auth
(auths.zoom_admin)
params
Meeting ID

The meeting ID or UUID

 
string ·params.meetingId
Action

The recording delete action. trash: Move recording to the trash. delete: Delete recording permanently

string ·params.action
code
async (params, auths) => {
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
}
19
const axios = require("axios")

// See the API docs: https://marketplace.zoom.us/docs/api-reference/zoom-api/cloud-recording/recordingdelete
const config = {
  method: "DELETE",
  url: `https://api.zoom.us/v2/meetings/${params.meetingId}/recordings`,
  params: {
    action: params.action,
  },
  headers: {
    Authorization: `Bearer ${auths.zoom_admin.oauth_access_token}`,          
    "Content-Type": "application/json"
  }
}

// A 204 response indicates the recording was successfully deleted
return await axios(config)