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 will be 100% before uploading process finished

See original GitHub issue

Describe the issue

hey every body. in the first, sorry for my poor english language. i wrote some code for uploading some images and data together by formdata format in react-native. and i use node.js in backend side and every thing is ok. i can upload images. but problem has occurred when i want use onUploadProgress. then loaded parameter will be 100% immediately but the upload process take some minutes after that. just in record when i use ajax in js code it’s will be perfect so the problem is not from backend side. and it occurred just in react-native and the images select and crop by react-native-image-crop-picker.

here is my code:

Example Code


axios.post(api_url, formData, {
    onUploadProgress: progressEvent => {
        let {loaded, total} = progressEvent;
        console.log((loaded / total) * 100)
    },
    headers: {
        'Authorization: Bearer <authorization token>',
        'Content-Type': 'multipart/form-data'
    }
});

Expected behavior, if applicable

Environment

  • Axios Version 0.21.0
  • Node.js Version v14.15.1
  • OS: ubuntu 18.04
  • Additional Library Versions React Native 0.63.0

Additional context/Screenshots

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:7
  • Comments:22

github_iconTop GitHub Comments

8reactions
shannhastingscommented, Mar 10, 2021

I see the same issue. The onUploadProgress will ramp up to 100 pretty quick on a large file, but watching the network tab the file is still sending for a long time after progress has said it was 100. Then finally the promise will return. This does not have anything to do with localhost. Just upload a large file to say S3 and you will see, the onUploadProgress calls will finish WAY before the actual promise, i.e. the data, has been transmitted.

4reactions
snaptsoftcommented, Jun 1, 2021

Unfortunately also still seeing this issue using Expo 41.0 and React Native.

Read more comments on GitHub >

github_iconTop Results From Across the Web

axios onUploadProgress returns immediately 100% progress ...
React Native android returns first 0% then immediately 100% progress for file upload but in the case of iOS it perfectly shows the...
Read more >
Add upload progress to axios request - The Coders Blog
The load event is triggered when the upload process is completed. In axios, we can get the progress information from the onUploadProgress ......
Read more >
Implementing a file upload status progressbar with Axios ...
We can attach a method to this event with progressEvent as the ... than or equal to 100, as we need to show...
Read more >
Axios upload progress with progress bar tutorial - YouTube
Source code: https://openjavascript.info/2022/06/06/ upload -progress- ... This tutorial shows how to upload a file from a HTML form to an API ...
Read more >
React Tips & Tricks: Uploading a File With A Progress Bar
It comes with two built-ins callback hook to process progress data: onUploadProgress : send event during the upload phase;; onDownloadProgress : ...
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