0

I can already upload my files to s3. But I want to get the progress loaded in each file.

bucket.upload(params, function(err, data){
   console.log("File Uploaded Successfully");
}).on('httpUploadProgress', function(progress){
   console.log(progress.loaded / progress.total * 100);}

The problem with this code is. The progress returns some data but it does not identify that this data is for that single file.

Is there any way to find out if the return progress is for that single data?.

3 Answers 3

1

For those who came across the same issue. There's no need to hack the code actually. Just use this in the upload progress callback.

s3.upload(params, function (err, data) {
    ...
}).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.
});

I've posted an issue in the AWS SDK JS repo, and maybe there will be a better solution over time.

Sign up to request clarification or add additional context in comments.

Comments

0

Sorry for late answer (I am not even sure if you still need one).

I had the same problem, I forked their repo on github and made the solution myself.

here is alink of the updated aws-sdk-js repo that does what you need.

https://github.com/mohamed-kamal/aws-sdk-js-upload-progress

hope it helps.

Comments

0

this works for me.

S3.upload(params, options, function (err, data) {
          if (err) {
            reject("error");
          }
          alert("Successfully Uploaded!");
        }).on("httpUploadProgress", (progress) => {
          let uploaded = parseInt((progress.loaded * 100) / progress.total);
          this.setState({
            progress: uploaded,
            uploadText: "Uploading...",
            uploading: true,
          });
        });

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.