Skip to content
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

Avoid copying the whole file into RAM to detect its content type #214

Merged
merged 1 commit into from Sep 5, 2021

Conversation

jkawamoto
Copy link
Contributor

request.buildHTTP copies the whole files into RAM to detect their content types, but it increases RAM usage if there is a large file. Since http.DetectContentType only considers at most the first 512 bytes of data, we can avoid copying the whole data.

This PR fixes #213.

request.buildHTTP copies the whole files into RAM to detect their
content types, but it increases RAM usage if there is a large file.
Since http.DetectContentType only considers at most the first 512 bytes
of data, we can avoid copying the whole data.

Signed-off-by: Junpei Kawamoto <kawamoto.junpei@gmail.com>
@youyuanwu
Copy link
Member

LGTM.
Documentation:
https://pkg.go.dev/net/http#DetectContentType

@youyuanwu youyuanwu merged commit 715c788 into go-openapi:master Sep 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Uploading a large file increases RAM usage
2 participants