-
Notifications
You must be signed in to change notification settings - Fork 2.5k
fix: Empty last chunk case in resumable upload that is not a stream #1802
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
base: main
Are you sure you want to change the base?
Conversation
For an upload that inherits the MediaUpload class and is not a stream, if the size of the upload is exact multiples of the chunksize, the last chunk would be empty and the generated Content-Range header will result in "Bad Request". Details: "Failed to parse Content-Range header."
|
chalmerlowe
left a comment
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.
LGTM.
| # An empty file results in chunk_end = -1 and size = 0 | ||
| # sending "bytes 0--1/0" results in an invalid request | ||
| # Only add header "Content-Range" if chunk_end != -1 | ||
| if chunk_end - self.resumable_progress + 1 == 0 and chunk_end != -1: |
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.
This if only fires if chunk_end != -1. But in that case, the if below also fires, overwriting this particular header. So this block as written has no effect on the end result.
For an upload that inherits the MediaUpload class and is not a stream,
if the size of the upload is exact multiples of the chunksize, the last
chunk would be empty and the generated Content-Range header will result
in "Bad Request". Details: "Failed to parse Content-Range header."
Fixes #1801 🦕