-
Notifications
You must be signed in to change notification settings - Fork 216
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
feat: Add stream_file_content
parameter to upload methods
#890
Conversation
c1d065a
to
920cb03
Compare
Pull Request Test Coverage Report for Build 14313605139Details
💛 - Coveralls |
8d29fdf
to
9c5d09e
Compare
11578e9
to
157d3e9
Compare
Hi! For my understanding, I have a couple conceptual questions about this particular change:
|
Hi,
|
Sorry, my mistake - please feel free to ignore my point 2. Our application actually bypasses the |
|
It's possible that setting Unfortunately, I have not had time to try to plug in this change into our app to see if it works. Hence, I would not support or oppose merging this change as is, but I defer to your judgement. |
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, but do we need to add docs for this?
requests
library documentation states that:In the Box Python SDK, we use
requests-toolbelt
by default to avoid loading the entire file into memory before sending the request. This ensures better efficiency, especially for large files.However, 307 Temporary Redirects introduce a challenge when using streamed file uploads. Unlike 302 Found, which can change a POST request into a GET, a 307 redirect requires that the method and request body remain unchanged. This becomes an issue when the request body is a file stream, as the stream may already be exhausted when the redirect occurs. Since requests automatically follows redirects, the request is resent, but the file content may no longer be available.
To address this issue we have introduced
stream_file_content
parameter to upload methods. This allows you to choose between streaming the file (for memory efficiency) or loading it into memory first (to handle redirects correctly).Fixes: #887