Created
December 9, 2013 09:00
-
-
Save nagataka/7869365 to your computer and use it in GitHub Desktop.
Basic sample to list objects in S3 bucket using AWS SDK for JavaScript
※Not recommended, just a sample coz this code directly include security credentials...
This file contains 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<script src="https://sdk.amazonaws.com/js/aws-sdk-2.0.0-rc1.min.js"></script> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> | |
<script type="text/javascript"> | |
AWS.config.update({ | |
accessKeyId: ‘YOUR ACCESS KEY ID’, | |
secretAccessKey: ‘YOUR SECRET ACCESS KEY’ | |
}); | |
</script> | |
<script type="text/javascript"> | |
var s3Bucket = ‘BUCKET NAME’; | |
var bucketRegion = ‘REGION’; | |
function listObj(){ | |
var s3 = new AWS.S3({params: {Bucket: s3Bucket, Region: bucketRegion}}); | |
s3.listObjects(function(error, data){ | |
if(error){ | |
console.log(error); | |
}else{ | |
console.log(data); | |
} | |
}); | |
} | |
</script> | |
</head> | |
<body> | |
<button onclick="listObj()">S3 - list objects</button> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment