auths
objectURL to file you'd like to download
URL where you want to send the uploaded file
return
or this.key = 'value'
, pass input data to your code viaparams
, and maintain state across executions with$checkpoint.async
(event, steps, params) => {
}
const FormData = require('form-data');
const fs = require('fs');
const got = require("got")
const stream = require('stream');
const {promisify} = require('util');
const filePath = "/tmp/index.html"
// DOWNLOAD
const pipeline = promisify(stream.pipeline);
await pipeline(
got.stream(params.downloadURL),
fs.createWriteStream(filePath)
);
// UPLOAD
const form = new FormData()
const readStream = fs.createReadStream(filePath)
form.append('file', readStream, filePath)
return await got.post(params.uploadURL, { body: form })