-
-
Notifications
You must be signed in to change notification settings - Fork 365
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
Add upload progress callback #183
Comments
Did you try the |
Sorry, it seems I did not ask the question correctly. I need upload progress, not download progress. And onDownloadProgress doesn't help me. |
I see. We don't have that feature at the moment, but it would be nice to add. I think it could be done similarly to download progress. |
It cannot. Seems like a pretty bizarre thing to leave out of the spec, if you ask me. Until they're added, |
I realize that |
As long as we can determine the total bytes to be uploaded then absolutely :) |
I suppose if the body is just a plain stream, we'd only be able to provide how many bytes have been uploaded but not the total bytes, which may not be super useful. However, if the body is a Blob or a File (or anything that can be normalized to one of those), then we can use |
Really missing this for File uploads. You possible solution sound great @sholladay . |
can this be added yet? axios seems to have this feature. |
@supertiger1234 You are perfectly allowed to submit a PR, yes :) |
🤷 I wouldn't even be using a lib for fetching if I knew how. |
No, I don't think axios supports it for browser. It is only supported in nodejs. Right? |
Please make this :D |
For anyone who wants to try implementing this, take a look at #34 and use that as a reference. Once there's a rough draft, I'd be happy to review and help with the code. |
It seems this should now be possible with Chromium versions > 105. It would be great if it could be incorporated into ky! https://developer.chrome.com/articles/fetch-streaming-requests/#streaming-request-bodies Here's an example implementation: https://stackoverflow.com/a/52860605/19510854 |
I've looked into this a bit more and it wouldn't be as easy to implement in All in all, I don't see an addition like this making sense until |
@Murderlon #632 would you mind giving a review? |
The problem with #632 is that AFAIK it will crash in browsers other than Chrome which is not really acceptable IMO. FWIW this person on x implemented a tiny wrapper which uses fetch if the client supports upload progress over fetch, with fallback to XMLHTTPRequest:
I'm not sure if Alternatively one could make a modified version of the fetch polyfill that exposes its inner XMLHttpRequest object, then ky could hook into its |
True, but only if you provide an The only real alternative here is for us to ignore the option instead of throwing when it's not supported. But silently failing is bad behavior for a library. Instead, you could detect support in your app and selectively provide the To that end, I would be supportive of Ky exporting its feature detection mechanisms. Or moving them to
Yep, that's a good approach.
It's doable, especially if the goal is only to support this feature and not be a general purpose fallback for fetch. However, there are environments that only support fetch and not XMLHttpRequest, such as Deno, Node, and Cloudflare Workers. So it's only a partial solution. Whether the complexity is worth it, I'm not sure. I would be happy to look at a PR. |
Would be a big time saver for me, at least. |
Hello, I would like to add an image loading indicator. Is this possible when using this library?
The text was updated successfully, but these errors were encountered: