onUploadProgress & onDownloadProgress for node
See original GitHub issueIt 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:
- Created 5 years ago
- Reactions:3
- Comments:7 (3 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.
Hi @jasonsaayman , I’ve checked and the problem still occurs.