Repository navigation
[Feature] Support Chunk-Based and Resumable File Uploads #33197
Closed
marcuwynu23
started this conversation in
Feature Request
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
I have searched the existing feature requests, both open and closed, to make sure this is not a duplicate request.
The feature
Problem
Currently, uploading large media files can be problematic when the network connection is unstable or an upload gets interrupted.
If a large file upload fails midway, the client may need to restart the entire upload, resulting in wasted bandwidth and time. This is particularly frustrating when uploading large videos or backing up media libraries over mobile networks, VPNs, or unreliable internet connections.
Another challenge affects users who access their Immich instances through Cloudflare, particularly those using the Cloudflare Free plan.
Cloudflare has a maximum upload request body size of 100 MB on the Free plan. This can prevent users from uploading large media files through the Cloudflare proxy when a single upload request exceeds that limit.
Proposed solution
I would like to request support for chunk-based file uploads with resumable upload capabilities.
Instead of uploading an entire file in a single HTTP request, the client would split the file into smaller chunks (fragments) and upload them independently.
The server would track the received chunks and assemble them into the original file once all chunks have been successfully uploaded.
Expected behavior
File fragmentation: The client splits large files into smaller chunks before uploading.
Independent chunk uploads: Each chunk is uploaded separately and identified by a unique upload session ID and chunk index.
Upload tracking: The server maintains the status of received chunks.
Resume interrupted uploads: If an upload is interrupted, the client can resume by sending only the missing chunks instead of restarting the entire file.
File assembly: Once all chunks are received, the server assembles them in the correct order into the original file.
Integrity validation: Validate chunks and the final assembled file to ensure data integrity.
Configurable chunk size: Allow chunk sizes to be configured or automatically determined based on the upload environment.
Example scenario
Imagine uploading a 2 GB video file using 10 MB chunks.
The client divides the video into 200 chunks.
The server receives and stores each chunk independently.
The network connection drops after 120 chunks have been uploaded.
When connectivity is restored, the client checks the upload session and continues with the remaining 80 chunks.
The server assembles all 200 chunks into the original video.
The completed file continues through Immich's existing asset processing workflow.
Without chunk-based uploads, the client might have to upload the entire 2 GB file again.
Cloudflare Free plan compatibility
One of the biggest advantages of this feature would be improved compatibility for users who expose their Immich instances through Cloudflare.
Cloudflare Free plan currently has a 100 MB maximum upload request body size.
Chunk-based uploads could help work around this limitation by splitting large files into smaller HTTP requests that stay below Cloudflare's per-request upload limit.
For example:
A user wants to upload a 2 GB video through Cloudflare.
The client splits the video into smaller chunks, such as 10 MB each.
Each chunk is sent as an individual HTTP request through Cloudflare.
Cloudflare processes each request because it is below the request body size limit.
The Immich server receives and assembles all chunks into the original 2 GB video.
This would allow users to upload large media files through Cloudflare's Free plan without needing to bypass the Cloudflare proxy or upgrade their Cloudflare subscription solely to accommodate large upload requests.
It would be especially beneficial for self-hosted Immich users who rely on Cloudflare for DNS, proxying, and remote access.
Benefits
Reliable uploads: Better handling of large photos and videos.
Resumable uploads: Resume interrupted uploads without starting over.
Cloudflare compatibility: Work around Cloudflare's per-request upload size restriction by sending smaller chunks.
Reduced bandwidth consumption: Avoid retransmitting entire files when only a few chunks failed.
Better mobile experience: More reliable backups over unstable or slow network connections.
Improved upload performance: Potentially increase upload throughput through configurable concurrent chunk transfers.
Self-hosting flexibility: Make Immich more accessible to users running their instances behind reverse proxies and CDN services.
Implementation considerations
The implementation could use an existing resumable upload protocol such as tus or a custom chunk-upload API designed around Immich's existing upload architecture.
Some considerations:
Maintain backward compatibility with the existing upload mechanism.
Use unique upload session IDs to identify individual file uploads.
Track uploaded chunks and prevent duplicate or incomplete assembly.
Implement upload session expiration and cleanup for abandoned uploads.
Validate chunk integrity and the final assembled file.
Support configurable chunk sizes and optional concurrent uploads.
Ensure compatibility with the existing asset upload and processing pipeline.
The implementation approach is open for discussion.
Motivation
Immich is frequently used to back up large personal photo and video libraries. Upload reliability is an important part of that experience.
Chunk-based resumable uploads would make Immich more resilient, especially when uploading large files over mobile networks, VPN connections, unstable internet connections, and reverse proxies with request-size limitations.
Additionally, this feature would make Immich more convenient for self-hosted users who rely on Cloudflare's Free plan to expose their instances remotely.
I believe this would be a valuable improvement to Immich's upload infrastructure and overall backup experience.
Platform
All reactions