OpenAPITools / OpenAPITools/openapi-generator
[REQ] Python file_type streaming upload
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the described get_file_data_and_close_file function and inspect how generated Python clients build multipart request bodies. Read the linked urllib3 multipart streaming support pull request for the upstream constraints. Done means file-like uploads can stream without materialising their contents in memory.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100