auths
objectreturn
or this.key = 'value'
, pass input data to your code viaparams
, and maintain state across executions with$checkpoint.async
(event, steps, params) => {
}
const axios = require('axios')
const config = {
method: 'GET',
url: `https://res.cloudinary.com/da5lyi17v/image/upload/v1599671104/${params.target_download_filename}`,
responseType: 'arraybuffer',
}
const resp = await axios(config)
const fs = require("fs");
const buffer = Buffer.from(resp.data.toString('base64'), "base64");
fs.writeFileSync(`/tmp/${params.target_download_filename}`, buffer);
this.filename = params.target_download_filename;
Name of the attachment file to upload. Must exist in the related workflow's /tmp
folder.
async
(params, auths) => {
}
//See the API docs: https://api.twistapp.com/v3/#upload-an-attachment
//See a workflow example of this action: https://pipedream.com/@sergio/twist-upload-attachment-p_n1Cnm9/edit
const FormData = require('form-data');
const fs = require("fs");
const uuid = require('uuid-random');
data = new FormData();
const file = fs.createReadStream(`/tmp/${params.filename}`);
data.append('attachment_id', uuid());
data.append('filename', params.filename);
data.append('file', file);
return await require("@pipedreamhq/platform").axios(this, {
method: 'post',
url: `https://api.twist.com/api/v3/attachments/upload`,
headers: {
Authorization: `Bearer ${auths.twist.oauth_access_token}`,
"Content-Type": `multipart/form-data; boundary=${data._boundary}`
},
data
});