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.

onUploadProgress & onDownloadProgress for node

See original GitHub issue

It would be useful to have the feature of onUploadProgress and onDownloadProgress also in NodeJS.

Example:

const fs = require('fs');
const axios = require('axios');

var data = fs.readFileSync('test.txt');
axios.post('https://example.com/upload', data, {
  onUploadProgress: function (progressEvent) {
    console.log(Math.floor((progressEvent.loaded * 100) / progressEvent.total));
  }
}).then(function (response) {
  console.log(response);
}).catch(function (error) {
  console.log(error);
});

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:3
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
RikkiGibsoncommented, Sep 23, 2018

I wrote an adapter for axios to provide uniform behavior for these handlers among other things. You may benefit from seeing the code for it:

https://github.com/Azure/ms-rest-js/blob/3c131b37/lib/axiosHttpClient.ts#L103

BTW, your code may work better with fs.createReadStream as you won’t have to wait for the file to be completely read before starting to upload it.

0reactions
marek-siemieniuk-morawskicommented, Apr 29, 2021

Hi @jasonsaayman , I’ve checked and the problem still occurs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

axios onUploadProgress and onDownloadProgress not ...
The code provided works perfectly on the browser, but it does not work when running it from node, because when running axios in...
Read more >
PlaceQueryAutocompleteRequest | Google Maps Services ...
Documentation for Google Maps Services Node Client. ... onDownloadProgress: (progressEvent: any) => void ... Optional onUploadProgress.
Read more >
TaskAddOptionalParams interface - Microsoft Learn
onDownloadProgress. Callback which fires upon download progress. onUploadProgress. Callback which fires upon upload progress. timeout.
Read more >
Axios onDownloadProgress Example - CodeSandbox
dudusoterodudusotero. TemplateReact; Environmentcreate-react-app. Files. public. src. App.js. ProgressBar.js. api.js. hooks.js. index.js. service.js.
Read more >
Axios onUploadProgress
Axios onDownloadProgress not working. The code provided works perfectly on the browser, but it does not work when running it from node, because...
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