muxinc / upchunk

Uploads Chunks! Takes big files, splits them up, then uploads each one with care (and PUT requests).
MIT License
345 stars 46 forks source link

Track progress during chunk upload #25

Closed mmcc closed 4 years ago

mmcc commented 4 years ago

A common request has been for smoother progress updates during chunk upload. Currently, due to limitations to the Fetch API, we only update progress after a successful chunk upload. This makes the upload progress feel pretty halty, particularly if you're trying to build a progress bar.

Since upload progress isn't available in Fetch, this PR switches us over to using XHR instead. It feels weird to need to do that in 2020, but this feels like the best solution for the short to mid term.

API changes

None, this could theoretically be a patch release at least in terms of any public API. The progress event will maintain the current behavior, showing the current progress of the total upload, even when the progress event is firing from within the context of a single chunk.

The one thing to consider here, however, is if anyone could be relying on it using Fetch under the hood. I don't think so?

Other stuff

I bumped a bunch of dev dependencies to make dependabot shut up.

dylanjha commented 4 years ago

👏 this is much needed (closes #25)

this could theoretically be a patch release at least in terms of any public API. is if anyone could be relying on it using Fetch under the hood. I don't think so?

With regards to the last question. I don't think so either. But technically, the headers on each request are changing a bit, right? If the headers are even slightly different, it could in theory break someone using this library (for a non-mux upload).

This is AWESOME!! I will definitely pull in this change to https://github.com/vercel/next.js/tree/canary/examples/with-mux-video