tus / tus-android-client

The tus client for Android.
https://tus.io/
161 stars 46 forks source link

Progress callback is limited on Android #35

Closed kamendo closed 4 years ago

kamendo commented 4 years ago

On iOS we have a progress callback which is quite nice! On Android for the progress we are stuck with the chunk size (which will slow down the upload if its too small). Can we have a more responsive progress somehow?

Acconut commented 4 years ago

I agree a proper progress callback would be more useful but I am not sure if that's possible using HttpUrlConnection (the HTTP client that tus-java-client is using). Maybe switching to another HTTP stack, such as OkHttp, provides more flexibility here.

Would you be willing to look into a better approach here on your own as my time is very limited right now?

kamendo commented 4 years ago

the progress update could be improved by writing smaller portions than the chunk size(bytesRead) into the OutputStream output.write(buffer, 0, bytesRead);

I will do some testing and then post my findings.

Acconut commented 4 years ago

the progress update could be improved by writing smaller portions than the chunk size(bytesRead) into the OutputStream

Exactly. That's what you already can control using the setChunkSize method: https://tus.github.io/tus-java-client/javadoc/io/tus/java/client/TusUploader.html#setChunkSize-int-

I will do some testing and then post my findings.

Sure, looking forward to your feedback!

kamendo commented 4 years ago

Ahaaa, now it make sense 👍 So setChunkSize on iOS is not the same as setChunkSize on Android, but setRequestPayloadSize. This is what puzzled me for a while. I will close the issue as the progress works great with low values, 10x for the help!