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

Add streamed file upload #75

Merged
merged 1 commit into from
May 28, 2020
Merged

Conversation

jmreyes
Copy link
Contributor

@jmreyes jmreyes commented Apr 13, 2020

When uploading files, this library copies first the whole file in memory in order to build the POST body for the upload request.

Problem: large files may cause issues like the API consumer running out of memory. I have noticed this, for instance, when trying to upload some Windows ISOs using the Proxmox builder for Packer.

Solution in this PR: when possible, use MultiReader to stream the file directly from the reader into the request, without previously storing it in memory. In order to do so, the ContentLength header needs to be manually calculated and specified. To avoid breaking the API, this is only performed in case the Reader passed as the argument to Upload is a File: this way the file size can be obtained from the OS.

Of course, this PR open to any suggestions.

@ggongaware ggongaware merged commit c0fb1a1 into Telmate:master May 28, 2020
frostyfab pushed a commit to frostyfab/proxmox-api-go that referenced this pull request Nov 17, 2023
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.

2 participants