Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to monitor the 'progress' of the upload? #202

Closed
uinz opened this issue Sep 20, 2015 · 7 comments
Closed

How to monitor the 'progress' of the upload? #202

uinz opened this issue Sep 20, 2015 · 7 comments

Comments

@uinz
Copy link

uinz commented Sep 20, 2015

use XMLHttpRequest, i listener 'progress', as below:

var XHR = new XMLHttpRequest();
XHR.upload.addEventListener("progress", function(e) {
  if (e.lengthComputable) {      
    var percentComplete = Math.round(e.position * 100 / e.total);
    console.log(percentComplete);
  }
}, false);

How do this with fetch ?

@dgraham
Copy link
Contributor

dgraham commented Sep 20, 2015

Monitoring progress is not a feature of the Fetch API. Using XMLHttpRequest is the best way for now.

Bonus tip! You can use the triple back tick ``` to format code blocks in comment fields:
https://guides.github.com/features/mastering-markdown/#GitHub-flavored-markdown

@domenic
Copy link

domenic commented Sep 20, 2015

This should do the trick: https://gist.github.com/domenic/95e689d0be5e24fb08ec

@emilgpa
Copy link

emilgpa commented Sep 20, 2015

Did it plan to include it in the final specs?

@domenic
Copy link

domenic commented Sep 20, 2015

It is already included in the spec, in a different form; please see the above linked gist for how you can translate from the new form to the old form.

@emilgpa
Copy link

emilgpa commented Sep 20, 2015

ok, thanks you!

@uinz uinz closed this as completed Sep 28, 2015
@uinz
Copy link
Author

uinz commented Sep 28, 2015

ok. i got it. thanks much.

@wmertens
Copy link

wmertens commented Dec 3, 2015

@domenic I don't understand how to use that snippet to monitor upload progress - in the spec I can only see streams for the response object, not the request object…

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 8, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants