Uploads and Downloads
Strategies for moving content in and out of ScaiDrive. The right approach depends on file size, your network, and whether you need resumability.
When to use what#
| File size | Upload | Download |
|---|---|---|
| < 5 MB | Multipart POST | Single GET |
| 5–100 MB | Multipart POST | Single GET with retry |
| > 100 MB | Resumable upload session | Range requests |
| Large + flaky network | Resumable upload session | Range requests with retry |
| Already-synced clients | Block-level sync | GET /sync/download/{id} with range |
Simple upload#
The multipart endpoint is the default for most integrations. One POST, one file.
1 2 3 4 5 | |
1 2 3 4 5 6 7 8 9 10 | |
1 2 3 4 5 6 7 8 9 10 11 | |
Hard limit: 5 GB per request (tenant-configurable). For larger files use resumable uploads.
Simple download#
1 2 3 | |
1 2 3 4 5 6 7 8 9 | |
1 2 3 4 5 | |
Stream the response — don't buffer. Large files will OOM your process.
Range downloads#
For resumable downloads or partial reads:
1 2 3 | |
Server responds 206 Partial Content with Content-Range: bytes 1048576-2097151/48293123. Combine multiple range requests to reconstruct large files with retries.
For sync-path downloads that already know the target file ID:
1 2 3 | |
Same shape but dedicated to sync clients. Supports range_start/range_end as query parameters as an alternative to the Range header.
Resumable uploads#
For large files — especially over flaky networks — use the upload session API.
Step 1: create a session.
1 2 3 4 5 6 7 8 9 10 | |
Response:
1 2 3 4 5 6 | |
Step 2: upload chunks in any order (parallel is fine).
1 2 3 | |
Step 3: finalize. When all chunks are uploaded:
1 2 | |
Response contains the resulting file_id.
Sessions expire after 24 hours of inactivity. See Resumable Uploads for the full protocol including chunk-level checksums and deduplication hints.
Verifying downloads#
Every file has a checksum_sha256. Clients should verify after download:
1 2 3 4 5 6 7 8 9 10 11 12 | |
Content types and previews#
Uploaded files have their MIME type inferred from the multipart Content-Type, or from the file extension if the type is generic. You can override by passing Content-Type explicitly in the multipart part.
ScaiDrive doesn't transcode or preview content in the core API. For image thumbnails or document previews, integrate an upstream preview service — ScaiDrive gives you the bytes.
Performance tips#
- Compress before upload. ScaiDrive doesn't compress on the server. If your client gzips first, you save bandwidth and storage. Set
Content-Encoding: gzipon the multipart part for the server to record the pre-decompressed size. - Parallelize resumable chunks. Uploads from a single connection are bottlenecked by upstream bandwidth; 4–8 parallel chunk uploads saturate most links.
- Reuse connections. Use an HTTP client that keeps a connection pool (
httpx.Client, Node's defaultfetchwith keep-alive). - Skip duplicates. Before uploading, check if the file is already in the share (
checksum_sha256match). For block-level clients, the resumable protocol handles this with chunk-hash negotiation.
What's next#
- Resumable Uploads — the chunked upload protocol in detail.
- Files — file CRUD.
- Versioning and Deduplication — how uploads interact with dedup.