Skip to content

Instantly share code, notes, and snippets.

@jashmenn
Created March 23, 2020 15:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jashmenn/ae4fa39a1a35c3b1b5cd5dc07afe64e5 to your computer and use it in GitHub Desktop.
Save jashmenn/ae4fa39a1a35c3b1b5cd5dc07afe64e5 to your computer and use it in GitHub Desktop.
Simple example of uploading to S3 from the filesystem with Node.js - If you're trying to learn how to do this, checkout Fullstack Node.js https://newline.co/fullstack-nodejs
const fs = require('fs')
const AWS = require('aws-sdk')
const { promisify } = require('util')
const s3 = new AWS.S3()
s3.uploadP = promisify(s3.upload)
const params = {
Bucket: 'fullstack-printshop',
Key: 'profile-photos/thedude.jpg',
Body: fs.createReadStream('thedude.jpg')
}
(async function () {
await s3.uploadP(params)
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment