Reputation: 272
I am using AWS javascript SDK to upload a file to S3 using multipart upload.
// Use S3 ManagedUpload class as it supports multipart uploads
var upload = new AWS.S3.ManagedUpload({
params: {
Bucket: albumBucketName,
Key: photoKey,
Body: file,
ACL: "public-read"
}
});
But I would like to also show the speed at which the upload is happening in the UI. Document doesn't provide any API to get the speed. So would like to know how to calculate the upload speed.
regards Achuth
Upvotes: 0
Views: 541
Reputation: 10720
.on('httpUploadProgress', function(e) {
console.log(e.loaded);
});
You can use .on
listner , and e.loaded
will provide you the uploaded bytes value, which can be used to calculate percentage of upload.
new AWS.S3.ManagedUpload({
params: {
Bucket: albumBucketName,
Key: photoKey,
Body: file,
ACL: "public-read"
}
}).on('httpUploadProgress', function(e) {
console.log(e.loaded);
});
Upvotes: 1