Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

get all objects from s3 bucket nodejs

function s3Client() {
    // if code in local development the use local s3 
    let option = {
       
        region: '',
        apiVersion: '2006-03-01',

        httpOptions: {
            connectTimeout: 5000,
            timeout: 120000
          },
        maxRetries: 2,
    }  
 
    option['credentials'] = {
        accessKeyId: '',
        secretAccessKey: ''
        
    }
    //option['endpoint'] = ''
    //option['s3ForcePathStyle'] = true

    return new AWS.S3(option);
}

var AWS = require('aws-sdk');
var s3 = s3Client();

var params = {
    Bucket: ""
   };


function test(params) {
    s3.listObjectsV2(params, function(err, data) {
        if (err) console.log(err, err.stack); // an error occurred
        else {
            // console.log(data);
            if(data.IsTruncated) {
                console.log(data.Contents.length);
                if(data.NextContinuationToken){
                    params.ContinuationToken = data.NextContinuationToken;
                    test(params);
                }
            }
            else {
                console.log(data.Contents.length);
            }

        }  
    }); 
}


test(params);



Comment

PREVIOUS NEXT
Code Example
Javascript :: send data using axios 
Javascript :: how to decode jwt token at frontend 
Javascript :: case switch javascript 
Javascript :: add table header dynamically in jquery 
Javascript :: closures 
Javascript :: destructuring props in react 
Javascript :: get array by array of indices js 
Javascript :: object loop 
Javascript :: how to name a javascript variable 
Javascript :: axios get request 
Javascript :: jsonplaceholder typicode 
Javascript :: carousel in material ui react 
Javascript :: electron 
Javascript :: js ismobile detected 
Javascript :: javascript get response payload 
Javascript :: how to get current time using moment 
Javascript :: ?? javascript 
Javascript :: js push 
Javascript :: electronjs 
Javascript :: devtool google 
Javascript :: javascript detect when youtube video ends 
Javascript :: time complexity of slice javascript 
Javascript :: prop types in react 
Javascript :: apexcharts bar onclick index 
Javascript :: How to dispatch from another module vuex 
Javascript :: find the second largest number in an array javascript 
Javascript :: modify array js 
Javascript :: redis pub or sub nodejs 
Javascript :: angular route 
Javascript :: resize canvas 
ADD CONTENT
Topic
Content
Source link
Name
7+8 =