Created
June 19, 2020 12:56
-
-
Save juliusdejon/3b46e4f88a75d2aa776102ef06f64136 to your computer and use it in GitHub Desktop.
Consuming List Objects of s3, can be run on node by calling it `node s3ListObjects.js`
This file contains hidden or 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'); | |
require('dotenv').config(); | |
const s3 = new aws.S3({ | |
signatureVersion: process.env.S3_SIGNATURE_VERSION, | |
region: process.env.S3_REGION | |
}); | |
const params = { | |
Bucket: 'bucket_name' /* required */, | |
// ContinuationToken: 'STRING_VALUE', | |
Delimiter: '/', | |
// EncodingType: url, | |
// FetchOwner: true || false, | |
MaxKeys: '5', | |
Prefix: 'cms/' | |
// RequestPayer: requester, | |
// StartAfter: 'STRING_VALUE' | |
}; | |
s3.listObjectsV2(params, function(err, data) { | |
if (err) console.log(err, err.stack); | |
// an error occurred | |
else console.log(data); // successful response | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment