I'd like to be able to track an S3 file upload's progress (bytes uploaded out of bytes total).
Before anyone flags this as a dupe—it's not. Every other answer I've seen on StackOverflow is actually incorrect. If you do something like this:
s3
.putObject(
{
Bucket: 'xyz',
Key: 'wow.png',
Body: data,
},
(err, data) => {
console.log('done', err, data);
}
)
.on('httpUploadProgress', progress => {
console.log('Progress:', progress);
});
You get a single progress update, showing the total size:
Progress { loaded: 1082019, total: 1082019 }
This is not useful. What I'm looking for is a more fine-grained report of upload progress like you would normally see during an upload (no matter the file size.. 1MB or 100MB):
0% out of 100%
3% out of 100%
7% out of 100%
9% out of 100%
(etc)