Skip to content

Instantly share code, notes, and snippets.

@juliusdejon
Created June 19, 2020 12:56
Show Gist options
  • Save juliusdejon/3b46e4f88a75d2aa776102ef06f64136 to your computer and use it in GitHub Desktop.
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`
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