Skip to content

Use streaming for UploadFileReplace - #85

Merged
piotrbulinski merged 1 commit into
mainfrom
streaming-upload
Jun 17, 2026
Merged

Use streaming for UploadFileReplace#85
piotrbulinski merged 1 commit into
mainfrom
streaming-upload

Conversation

@piotrbulinski

Copy link
Copy Markdown
Contributor

This pull request refactors the UploadFileReplace method in files.go to use a streaming approach for constructing and sending multipart form data, rather than buffering the entire file in memory. This change improves memory efficiency, especially for large files.

File upload streaming improvements:

  • Switched from buffering the entire multipart request in memory using bytes.Buffer to streaming the multipart data via an io.Pipe, reducing memory usage for large file uploads.
  • The multipart form creation and file reading are now performed in a goroutine, writing directly to the pipe, which allows the HTTP request to read the data as it is being generated.

Minor cleanup:

  • Removed the unused import of bytes from files.go.

@piotrbulinski

Copy link
Copy Markdown
Contributor Author

@jonhenrik13 once #86 is merged, this branch can be updated and then it's ready for review as well.

@piotrbulinski
piotrbulinski merged commit 22949af into main Jun 17, 2026
6 checks passed
@piotrbulinski
piotrbulinski deleted the streaming-upload branch June 17, 2026 10:20
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