Example: Save uploaded file to Amazon S3
@dylburger
code:
data:privatelast updated:3 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 800,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.
stream_file_to_s3
Accepts a file URL, and streams the file to the provided S3 bucket/key
auth
(auths.aws)
params
FileUrl
{{event.body.image.url}}
string ·params.fileUrl
S3Bucket
 
string ·params.s3Bucket
S3Key
{{event.body.image.filename}}
string ·params.s3Key
code
async (params, auths) => {
1
2
3
4
5
6
7
8
9
10
11
12
13
14
}
15
const { fileUrl, s3Bucket, s3Key } = params
const { accessKeyId, secretAccessKey } = auths.aws
const AWS = require("aws-sdk")
const s3 = new AWS.S3({ accessKeyId, secretAccessKey })
const urlResponse = await require("axios").get(fileUrl, { responseType: 'stream' })
const s3Response = await s3.upload({
  Bucket: s3Bucket,
  Key: s3Key,
  ContentType: urlResponse.headers['content-type'],
  ContentLength: urlResponse.headers['content-length'],
  Body: urlResponse.data,
}).promise()
return (await s3Response).Location