Skip to content

Additional unnecessary call if the file size is divisble by requestPayloadSize #37

@luknow93

Description

@luknow93

Describe the bug
When trying to upload a file thats exactly divisible by requestPayloadSize. An additional empty PATCH request will be made that will result in 404.

The cause of it is that in uploadChunk() method you're finishing connection after bytesRemainingForRequest is reaching 0. uploadChunk() doesn't return -1 at this point.
On the server side the file is already "finished" since all bytes are there, but on the device an additional loop has to be made to receive -1 from uploadChunk(). But that additional call results in new connection being opened thats when being finished sends an empty body PATCH that results in 404 from the server, since for the server the upload already finished.

I guess a simple fix for that would be to move the openConnection() inside uploadChunk() a litte bit lower so that its called only if read didnt return -1

To Reproduce

  1. Follow the impl guide.
  2. Try to upload exactly 10MB file without changing any setup in uploader

Expected behavior
No additional call when theres nothing left to upload.

Setup details
Please provide following details, if applicable to your situation:

  • Any android version
  • tus-android-client v0.1.9
  • tus-java-client v0.4.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions