Created
May 7, 2021 09:55
-
-
Save nkhil/da270871d3df2cffb76912cdad563a75 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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