-
Notifications
You must be signed in to change notification settings - Fork 186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Fixed upload when data are coming from a dynamic source #1189
Conversation
Pull Request Test Coverage Report for Build #3139
💛 - Coveralls |
} | ||
|
||
/** | ||
* Returns content length. If the content length cannot be derermined |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
determined
bufferedSink.write(buffer, 0, n); | ||
totalWritten += n; | ||
if (progressListener != null) { | ||
progressListener.onProgressChanged(totalWritten, this.contentLength()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if contentLength()
returns -1. Would progress listener work correctly ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added details here:
* In case of file uploads which are coming from a dynamic stream the file size cannot be determined and |
in short total size will be -1 but bytes written should be properly returned.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe close the issue with this pr
With OkHttp not really working with stream we have our own solution. But it can work with them as long as we tell it that content size if unknown.
This was the source of the problem in the #1183 where two threads started and one was feeding data to other. First was downloading a file second was uploading new version.
This should also address failing uploads when dealing with a stream which full size cannot be determined upfront (#1190 ).