Start upload (the easiest way to reproduce is, to make the upload sequential and throttle network connection to 3G or slow)
First file is uploading and progress bar + loaded is increasing
After the first file is completed the progress & loaded is decreased
Reason
On loadend event the event.total and event.loaded are taken the Content-Length header from the response (see here).
In my case this bug occures because the uploaded file was 12000 bytes and the Content-Length was 300 bytes, because my i my response body there is a json like { successful: true }
I think, there is not correct to set the Content-Length as file.size, because this is only correct, when i return after the upload the uploaded image.
While debugging, i have found an older issue. In this issue there was tried so fix this problem, by adding a check for total = 0 bytes (https://github.com/adopted-ember-addons/ember-file-upload/pull/475),
This means, that the progress & loaded works only when i return with status 200 & no body.
Possible fix
The file.size should only be set in onloadstart event
In Event onprogress set always only file.loaded
In event onloadend (when file is uploaded) we should set file.loaded equal to file.size
Steps to reproduce
Reason
On
loadend
event theevent.total
andevent.loaded
are taken theContent-Length
header from the response (see here). In my case this bug occures because the uploaded file was 12000 bytes and the Content-Length was 300 bytes, because my i my response body there is a json like{ successful: true }
I think, there is not correct to set the
Content-Length
asfile.size
, because this is only correct, when i return after the upload the uploaded image.While debugging, i have found an older issue. In this issue there was tried so fix this problem, by adding a check for total = 0 bytes (https://github.com/adopted-ember-addons/ember-file-upload/pull/475), This means, that the progress & loaded works only when i return with status 200 & no body.
Possible fix
file.size
should only be set inonloadstart
eventonprogress
set always onlyfile.loaded
onloadend
(when file is uploaded) we should setfile.loaded
equal tofile.size
Actual code parts: https://github.com/adopted-ember-addons/ember-file-upload/blob/d2ac4b21b99d764a715fbde8625750d7cadf8c68/ember-file-upload/src/system/upload.ts#L90-L97
https://github.com/adopted-ember-addons/ember-file-upload/blob/d2ac4b21b99d764a715fbde8625750d7cadf8c68/ember-file-upload/src/system/http-request.ts#L85-L90