Skip to content

feat(synology): implement streaming for large file uploads#1485

Merged
mengyushen merged 2 commits into
dtinit:masterfrom
SynologyOpenSource:synology-large-file-upload
Mar 18, 2026
Merged

feat(synology): implement streaming for large file uploads#1485
mengyushen merged 2 commits into
dtinit:masterfrom
SynologyOpenSource:synology-large-file-upload

Conversation

@simonxander
Copy link
Copy Markdown
Collaborator

Goal

The goal of this change is to support large file uploads for SynologyDTPService by implementing streaming. This resolves potential OutOfMemoryError (OOM) issues that occurred when large media files were fully buffered into memory during the transfer process.

Changes

  • Streaming Uploads: Replaced ByteStreams.toByteArray() with a custom RequestBody implementation using Okio to stream data directly from the source (JobStore or URL) to the network sink.
  • Repeatable Streams for Retries: Introduced RequestBodyGenerator, a functional interface that allows the sendPostRequest method to re-open the InputStream during retries. This ensures that even if a stream is consumed during a failed attempt, it can be reset for the next retry.

Testing

  • New Unit Tests: Added SynologyDTPServiceOOMTest to verify 1GB streaming.
  • Updated Unit Tests: Updated SynologyDTPServiceTest to accommodate the new RequestBodyGenerator pattern and added cases for getMediaInputStreamWrapper.

Key changes:
- Implemented streaming uploads using Okio and a custom RequestBody.
- Introduced RequestBodyGenerator to support retries by re-opening streams.
- Refactored stream retrieval into getMediaInputStreamWrapper.
- Added SynologyDTPServiceOOMTest to verify 1GB+ uploads without OOM.
@simonxander simonxander force-pushed the synology-large-file-upload branch from d2c21d2 to 4745bc8 Compare March 17, 2026 03:29
Reviewer: amychen

Ref: dlt1/data-transfer-project#15
@yukthagaduputi
Copy link
Copy Markdown
Collaborator

Looks Good to me

@mengyushen mengyushen merged commit 15ba78f into dtinit:master Mar 18, 2026
6 checks passed
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.

3 participants