2019-01-23 02:33:13 +00:00
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
2018-10-11 14:17:57 -07:00
// ABOUT THIS NODE.JS SAMPLE: This sample is part of the SDK for JavaScript Developer Guide topic at
// https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/s3-example-creating-buckets.html
2019-01-23 02:33:13 +00:00
// snippet-start:[s3.JavaScript.buckets.listObjects]
2018-10-11 14:17:57 -07:00
// Load the AWS SDK for Node.js
var AWS = require ( "aws-sdk" ) ;
// Set the region
AWS . config . update ( { region : "REGION" } ) ;
// Create S3 service object
s3 = new AWS . S3 ( { apiVersion : "2006-03-01" } ) ;
2019-02-01 00:13:14 +00:00
// Create the parameters for calling listObjects
2019-01-23 02:33:13 +00:00
var bucketParams = {
2018-10-11 14:17:57 -07:00
Bucket : "BUCKET_NAME" ,
} ;
2019-02-01 00:13:14 +00:00
// Call S3 to obtain a list of the objects in the bucket
2019-01-23 02:33:13 +00:00
s3 . listObjects ( bucketParams , function ( err , data ) {
2018-10-11 14:17:57 -07:00
if ( err ) {
console . log ( "Error" , err ) ;
} else {
console . log ( "Success" , data ) ;
}
} ) ;
2019-01-23 02:33:13 +00:00
// snippet-end:[s3.JavaScript.buckets.listObjects]