question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Upload progress callback

See original GitHub issue

This would solve…

Currently there’s no way to get upload progress other than passing a stream. What if we’re passing a 10MB Buffer instead? Readable.from(buffer) and we’re storing it twice, which is unfortunate. So for an application that handles 100MB at a time we would need 200MB.

The implementation should look like…

  client.dispatch({
    path: '/',
    method: 'GET',
    headers: {
      'x-foo': 'bar'
    }
  }, {
...
    onUploadProgress: (bytes) => {
      console.log(`onUploadProgress : ${bytes} bytes in total`)
    },
...
  })

I have also considered…

Reading the state from the underlying socket. It’s not so nice.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
mcollinacommented, Jun 1, 2021

This would be a nice feature to add! I think we should make the callback arrive to https://github.com/nodejs/undici/blob/b33dffa76d34d31a7ee189ac72c5ace5ef75e7f3/lib/client.js#L1423 and call it afterwards (if it’s present).

0reactions
mcollinacommented, Jun 20, 2021

I’m questioning a bit the use case… I would not allocate a massive buffer in the first place.

Read more comments on GitHub >

github_iconTop Results From Across the Web

File Upload Progress bar - CodePen
HTML ; 1. <h2>HTML5 File Upload Progress Bar Tutorial</h2> ; 2. <form id="upload_form" enctype="multipart/form-data" method="post"> ; 3. <input type="file" name=" ...
Read more >
File Upload Progress Bar with JS and PHP - CodeShack
In this tutorial, we'll be creating a multiple file upload interface with a progress bar using JavaScript (AJAX) and PHP.
Read more >
How to Create Graphical File Upload Progress Bars in HTML5 ...
File upload progress bars provide essential user feedback but they've been notoriously difficult to implement. Until now that is. Both Firefox ...
Read more >
Add upload progress callback · Issue #183 · sindresorhus/ky
I need upload progress, not download progress. And onDownloadProgress doesn't help me.
Read more >
File Upload with Progress Bar HTML CSS & JavaScript
File Upload JavaScript with Progress Bar [Source Codes] · html lang="en"> · head> · meta charset="UTF-8"> · meta name="viewport" content="width= ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found