mirror of
https://github.com/Telmate/proxmox-api-go.git
synced 2026-04-25 23:45:55 +03:00
[PR #75] [MERGED] Add streamed file upload #206
Labels
No labels
good first issue
issue/confirmed
issue/critical
proposal/accepted
pull-request
type/bug
type/enhancement
type/feature
type/question
type/refactoring
type/testing
type/testing
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/proxmox-api-go#206
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Telmate/proxmox-api-go/pull/75
Author: @jmreyes
Created: 4/13/2020
Status: ✅ Merged
Merged: 5/28/2020
Merged by: @ggongaware
Base:
master← Head:streaming-upload📝 Commits (1)
7ed1017Add streamed file upload📊 Changes
1 file changed (+59 additions, -1 deletions)
View changed files
📝
proxmox/client.go(+59 -1)📄 Description
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.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.