auths
objectreturn
or this.key = 'value'
, pass input data to your code viaparams
, and maintain state across executions with$checkpoint.async
(event, steps) => {
}
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}`
The URL of the file you want to stream to Google Drive
The filename you want to assign to the file in Google Drive
A list of parent folder IDs, entered manually or retrieved from a previous file list operation
The MIME / Media type of the file
async
(params, auths) => {
}
const {google} = require('googleapis')
const got = require('got');
// First, get a ReadableStream for the content of the URL you want to download
const urlResponse = await got.stream(params.fileURL)
const driveAuth = new google.auth.OAuth2()
driveAuth.setCredentials({ access_token: auths.google_drive.oauth_access_token })
const drive = await google.drive({ version: 'v3', auth: driveAuth });
this.uploadResponse = (await drive.files.create({
resource: {
name: params.filename,
originalFilename: params.filename,
parents: params.parents,
},
media: {
mimeType: params.filetype,
uploadType: "media",
body: urlResponse,
},
fields: '*'
})).data
async
params => {
}
const options = {
subject: params.subject,
text: params.text,
}
if (params.html) {
options.html = params.html
}
if (params.include_collaborators) {
options.include_collaborators = params.include_collaborators
}
$send.email(options)