Right now I am using the javascript SDK to access my s3 bucket and it works fine but I have hard-coded all my credentials in the javascript directly but in the SDK they are saying you can store these in the AWS.config object and I dont know how to do this. Also, the online resources are not informative so can someone please let me know how to do this or any other better way to do this instead of hard-coding the credentials?
<script type="text/javascript">
AWS.config.accessKeyId = 'dddddddddd';
AWS.config.secretAccessKey = 'rrrrrrrrrrrrrrrreeeeeeeeeeeeeeeeeeeee';
AWS.config.region = 'us-east-1';
// create the AWS.Request object
var bucket = new AWS.S3({ params: { Bucket: 'some.bucket' } });
bucket.listObjects(function (err, data) {
if (err) {
document.getElementById('status').innerHTML =
'Could not load objects from S3';
} else {
document.getElementById('status').innerHTML =
'Loaded ' + data.Contents.length + ' items from S3';
for (var i = 0; i < data.Contents.length; i++) {
document.getElementById('objects').innerHTML +=
'<li>' + data.Contents[i].Key + '</li>';
}
}
});
</script>
accessKeyIdandsecreteAccessKeyis deprecated. I chose to use this method: docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/…