-
-
Notifications
You must be signed in to change notification settings - Fork 771
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
Mark endpoints for streaming uploads #1371
Mark endpoints for streaming uploads #1371
Conversation
Adds an "x-stream-upload" option that users can add to a requestBody to specify that it should be read as a stream rather than loading the entire request into memory. This allows it to be streamed to disk, which is necessary to support large requests like file uploads.
Hi @tst-lsavoie, thanks for the PR.
|
@RobbeSneyders I didn't use the I changed the base branch to |
I've been looking into this a bit more, and I would suggest the following solution. Define a We can then assign
You can then prevent stream consumption in connexion by
WDYT? |
You can find a quick and dirty PoC of the solution here: |
I think I understand the proposed solution. So, if the content type was not form or JSON, and if the user didn't add a parameter for the body to their function, then the stream would be available. I could see that working. I worry about it for the future, though. One small, innocent looking update that accesses the request body could break it. Hopefully testing would catch that, but it's not guaranteed. We'd have to do some refactoring for the OpenAPI 3 version of the code as well: The biggest problem is going to be time. I'm not sure when I'll next have a good chunk of time to focus on this issue. |
This is great! I have used it marking my endpoint with x-stream-upload and work like a charm, thanks :) |
Fixed by #1618 |
Fixes #592 based on the suggestion by @MatteoRagni: #592 (comment).
Also Fixes #1332, I think.
Changes proposed in this pull request:
x-stream-upload
option for requests. When this is specified, connexion will passflask.request.stream
as therequest.body
instead of callingget_data()
. This allows streaming uploads to disk instead of reading the entire file into memory.