[REQ] Python file_type streaming upload
Created by: skinkie
Is your feature request related to a problem? Please describe.
When using a large file, python's requests will serialise this to memory. If the form rendering is bigger than the available memory, this will fail.
Describe the solution you'd like
Analogue to https://pypi.org/project/requests-toolbelt/ a way where file like objects offered via a "open(..., 'rb')" or "open(..., 'rb', buffered=0)" interface are never encoded to a body prior to sending.
Describe alternatives you've considered
I was hoping it worked out of the box.
This is my guess that describes the actual problem, it materialises the file contents.
def get_file_data_and_close_file(file_instance: io.IOBase) -> bytes:
file_data = file_instance.read()
file_instance.close()
return file_data
Urllib3 upstream multipart streaming support. https://github.com/urllib3/urllib3/pull/2331