AWS SDK JavaScript: how display upload progress of AWS.S3.putObject?
amazon-s3, amazon-web-services, file-upload, html, javascript
Solution
Rather than using the `s3.PutObject` function why not instead use the ManagedUpload function.
It has been specifically developed to allow you to hook into a httpUploadProgress event that should allow the updating of your progress bar to be implemented fairly easily.
Problem
I'm developing a JavaScript client to upload files directly to Amazon S3. ``` <input type="file" id="file-chooser" /> <button id="upload-button">Upload to S3</button> <div id="results"></div> <script type="text/javascript"> var bucket = new AWS.S3({params: {Bucket: 'myBucket'}}); var fileChooser = document.getElementById('file-chooser'); var button = document.getElementById('upload-button'); var results = document.getElementById('results'); button.addEventListener('click', function() { var file = fileChooser.files[0]; if (file) { results.innerHTML = ''; var params = {Key: file.name, ContentType: file.type, Body: file}; bucket.putObject(params, function (err, data) { results.innerHTML = err ? 'ERROR!' : 'UPLOADED.'; }); } else { results.innerHTML = 'Nothing to upload.'; } }, false); </script> ``` The example from Amazon documentation works fine, but it doesn't provide any feedback on the upload progress. Any ideas? Thanks