Harsh Vardhan
Harsh Vardhan

Reputation: 1

Get status of upload progress while uploading files to S3 using AWS Amplify

I am uploading a file through angular to S3 using aws-amplify sdk and i want to see how much file has been uploaded to the bucket.

Storage.put(id, name)
    .then (result => console.log(result))
    .catch(err => console.log(err)).on('httpUploadProgress', function(progress) {
    // Here you can use `this.body` to determine which file this particular
    // event is related to and use that info to calculate overall progress.
});

This does not work and i cannot seem to find a solution for it.

Upvotes: 0

Views: 2537

Answers (2)

Vivid Wombat
Vivid Wombat

Reputation: 31

Amplify docs include this now - https://aws-amplify.github.io/docs/js/storage#put

Upvotes: 3

Niroshan Ranapathi
Niroshan Ranapathi

Reputation: 3047

Upload progress is possible to get for the Storage API (aws-amplify). But it is still not documented in official doc.

Try this

Storage.put(id, name, {
  progressCallback(progress) {
    console.log(`Uploaded percentage: ${progress.loaded}/${progress.total}`);
  },
});

Upvotes: 2

Related Questions