dilab / resumable.php

PHP backend for resumable.js
http://www.startutorial.com/articles/view/resumable-file-upload-part-1
MIT License
42 stars 40 forks source link

Improved #36

Closed abilogos closed 10 months ago

abilogos commented 10 months ago

Hello @dilab .

I have made a couple of improvement in order to revive the library with new dependency versions. fixed test cases depredations. & a few bugfixes

williamdes commented 10 months ago

That's funny, I did quite some similar changes in https://github.com/code-lts/resumable.php

And infact you closed a bug: #30 by 5172968603afe4c60ffaeba89d754c2ed7220056 I fixed the tests this PR broke in #37

abilogos commented 10 months ago

@williamdes yes that was a wired one since it was considering the chunk before the last one as the final chunk.

but after I think I had fixed that, I have found out it raised another issue. then after investigating the resumablejs front-end library I have found out that some configuration there to make the the last chunk bigger than the other unless you make forceChunkSize option as true.

for example : if your uploading file is 3.5 MB and your chunk size is 1 MB => it chunks your file into 1MB 1MB 1.5MB and if you set the forceChunkSize option it would chunk the file as 1MB 1MB 1MB 0.5MB

and in the resumable.php the assumption was forceChunkSize is always true (which was defaulted to false) and it was considering the-one-before-last as the final chunk.

but hopefully the resuamblejs sends a header resumableTotalChunks so with use of that, we dont need to calculate the last chunk in the backend, and the bug which made the trouble would be fixed. so I have fixed the new issue with this https://github.com/dilab/resumable.php/pull/36/commits/72f438c03ac14013ceffbda003643e4f0a026dac and the problem get solved

williamdes commented 10 months ago

Exactly, I came to the same conclusion and implemented total chunks 😄