Feature: support operate the underlying incoming data for uploading large file #3042
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
For file uploading, default behaviour will
ReadForm
and write data to new temporary file if oversizemaxMemory
.If temporary directory size is too small, it will fail for uploading large file and even consume OS memory since copy to buffer.
Inspired by Flask, Flask
request.stream.read
will read underlying socket data directly if payload found. Refer to: https://werkzeug.palletsprojects.com/en/2.0.x/wsgi/#werkzeug.wsgi.LimitedStreamThis method makes assumptions because the request payload exists for operating
POST/PATCH/PUT
.A simple demo for uploading 5G large file in low memory based on docker:
Signed-off-by: Chenyang Yan [email protected]
P.S.: if it's useful, I'll do the rest of the work, e.g.: update README.md, etc.