feat: Add stream_file_content parameter to upload methods#890
feat: Add stream_file_content parameter to upload methods#890lukaszsocha2 merged 4 commits intomainfrom
stream_file_content parameter to upload methods#890Conversation
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. |
congminh1254
left a comment
There was a problem hiding this comment.
LGTM, but do we need to add docs for this?
requestslibrary documentation states that:In the Box Python SDK, we use
requests-toolbeltby 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_contentparameter 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