Skip to content

Instantly share code, notes, and snippets.

@nkhil
Created May 7, 2021 09:55
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 nkhil/da270871d3df2cffb76912cdad563a75 to your computer and use it in GitHub Desktop.
Save nkhil/da270871d3df2cffb76912cdad563a75 to your computer and use it in GitHub Desktop.
const AWS = require('aws-sdk')
// a function that returns a promise
function copyFileToS3() {
// initialise AWS S3
const s3 = new AWS.S3({
accessKeyId: 'whatever',
secretAccessKey: 'whatever',
endpoint: 'http://localhost:4566', // localstack is running on port 4566. Imagine this was the real S3 endpoint
s3ForcePathStyle: true,
})
const copyObjectParams = {
Bucket: 'some-bucket',
CopySource: 'some-bucket/some/path/myfile.json,
Key: 'some-bucket/some/other/path/myfile.json',
}
return s3.copyObject(copyObjectParams).promise()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment