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

upload progress? #21

Closed
radubrehar opened this Issue Feb 20, 2015 · 10 comments

Comments

8 participants
@radubrehar

radubrehar commented Feb 20, 2015

Is there any way I can attach a progress listener to the xhr.upload object used in fetch?

xhr.upload.addEventListener('progress', function(){ ... })

since I use fetch to upload files (with FormData), I would find this very useful.

I initially reported this at github/fetch#89, and was suggested to have it reported here

@annevk

This comment has been minimized.

Show comment
Hide comment
@annevk

annevk Feb 20, 2015

Member

The native fetch() API implemented by browsers does not use XMLHttpRequest underneath. The eventual API for progress is building something on https://streams.spec.whatwg.org/ which https://github.com/yutakahirano/fetch-with-streams/ is adding to fetch().

Member

annevk commented Feb 20, 2015

The native fetch() API implemented by browsers does not use XMLHttpRequest underneath. The eventual API for progress is building something on https://streams.spec.whatwg.org/ which https://github.com/yutakahirano/fetch-with-streams/ is adding to fetch().

@cusspvz

This comment has been minimized.

Show comment
Hide comment
@cusspvz

cusspvz Mar 30, 2017

The native fetch() API implemented by browsers does not use XMLHttpRequest underneath.

But yet, it does not mean it couldn't be pondered and proposed.

Native promises are not yet cancellable and/or progressed, so my proposal would be for a callback on the second argument object of fetch which would receive a ProgressEvent (which is already present because of XHR).

As a polyfill, it could be easily placed with the progress event listener as stated by the OP.

API Example:

aync fetchSometing ( form ) {
  const res = await fetch('/upload', {
    method: 'POST',
    body: form,
    progress: (e) => { console.log(`Progress: ${e.loaded/e.total}%`) }
  })
}

cusspvz commented Mar 30, 2017

The native fetch() API implemented by browsers does not use XMLHttpRequest underneath.

But yet, it does not mean it couldn't be pondered and proposed.

Native promises are not yet cancellable and/or progressed, so my proposal would be for a callback on the second argument object of fetch which would receive a ProgressEvent (which is already present because of XHR).

As a polyfill, it could be easily placed with the progress event listener as stated by the OP.

API Example:

aync fetchSometing ( form ) {
  const res = await fetch('/upload', {
    method: 'POST',
    body: form,
    progress: (e) => { console.log(`Progress: ${e.loaded/e.total}%`) }
  })
}
@NitroBAY

This comment has been minimized.

Show comment
Hide comment
@NitroBAY

NitroBAY Jul 1, 2017

So why @cusspvz's idea doesn't seem to have been taken in consideration ?
It seems a good idea to me.

NitroBAY commented Jul 1, 2017

So why @cusspvz's idea doesn't seem to have been taken in consideration ?
It seems a good idea to me.

@jakearchibald

This comment has been minimized.

Show comment
Hide comment
@jakearchibald

jakearchibald Jul 1, 2017

Collaborator

Discussion around fetch observation is over at #447.

Collaborator

jakearchibald commented Jul 1, 2017

Discussion around fetch observation is over at #447.

@caub

This comment has been minimized.

Show comment
Hide comment
@caub

caub Apr 15, 2018

The discussion in #447 was more about fetch cancellation, now it's added in the spec with AbortController

For fetch upload progress, it would be great, that's the only missing thing compared to XHR

caub commented Apr 15, 2018

The discussion in #447 was more about fetch cancellation, now it's added in the spec with AbortController

For fetch upload progress, it would be great, that's the only missing thing compared to XHR

@annevk

This comment has been minimized.

Show comment
Hide comment
@annevk

annevk Apr 15, 2018

Member

Ah, thanks for pinging this thread. Observation moved to #607. Hope that helps.

Member

annevk commented Apr 15, 2018

Ah, thanks for pinging this thread. Observation moved to #607. Hope that helps.

@oliverjanik

This comment has been minimized.

Show comment
Hide comment
@oliverjanik

oliverjanik Jun 8, 2018

Please reopen this issue. This is real world scenario on millions of websites daily. Fetch needs needs an upload progress. period. We've been stuck with the bad XHR API for decades now.

Yet, no one seems concerned that despite all the efforts and years of debates that went into fetch it does not deliver.

Can everyone on this committee stop treating it as a hot potato a deal with it.

oliverjanik commented Jun 8, 2018

Please reopen this issue. This is real world scenario on millions of websites daily. Fetch needs needs an upload progress. period. We've been stuck with the bad XHR API for decades now.

Yet, no one seems concerned that despite all the efforts and years of debates that went into fetch it does not deliver.

Can everyone on this committee stop treating it as a hot potato a deal with it.

@annevk

This comment has been minimized.

Show comment
Hide comment
@annevk

annevk Jun 8, 2018

Member

There is no committee… And this issue is closed because there is a more focused issue around a concrete proposal towards addressing this.

Member

annevk commented Jun 8, 2018

There is no committee… And this issue is closed because there is a more focused issue around a concrete proposal towards addressing this.

@mindtonic

This comment has been minimized.

Show comment
Hide comment
@mindtonic

mindtonic Jun 26, 2018

@oliverjanik Use the .on('progress', ...... ) feature of Superagent. https://github.com/visionmedia/superagent

mindtonic commented Jun 26, 2018

@oliverjanik Use the .on('progress', ...... ) feature of Superagent. https://github.com/visionmedia/superagent

@oliverjanik

This comment has been minimized.

Show comment
Hide comment
@oliverjanik

oliverjanik Jun 27, 2018

No thanks, I like my batteries included.

oliverjanik commented Jun 27, 2018

No thanks, I like my batteries included.

@caub caub referenced this issue Jul 1, 2018

Closed

upload progress? #89

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment