I have an array for example named yourArray. var yourArray = [];
When I get object names with listObjects from s3, I want to push this object names to the array.
var params ={
Bucket: 'exBucket',
Prefix: 'somePrefix'
};
s3.listObjects(params, function(Err, Data){
if(!Err){
for (var i = 0; i < Data.Contents.length; i++){
console.log('Listed: ', Data.Contents[i].Key);
yourArray.push(Data.Contents[i].Key);
}};
});
Here, console.log('Listed: ', Data.Contents[i].Key);
gives me the all names. But yourArray.push(Data.Contents[i].Key);
doesnt push the names and array is still empty. Where is the mistake ?
Aucun commentaire:
Enregistrer un commentaire