2026-04-11 20:58:34 +02:00
# Chunked Uploads
2026-04-22 07:50:41 +02:00
OxiCloud exposes resumable chunked uploads under `/api/uploads` . The protocol is TUS-like in spirit, but the concrete API is OxiCloud-specific: create a session, stream chunks with `PATCH` , inspect progress with `HEAD` , then finalize the assembled file.
2026-04-11 20:58:34 +02:00
2026-04-22 07:50:41 +02:00
## Upload Flow
2026-04-11 20:58:34 +02:00
2026-04-22 07:50:41 +02:00
1. Create an upload session with `POST /api/uploads`
2. Upload each chunk with `PATCH /api/uploads/{upload_id}?chunk_index=N`
3. Optionally inspect progress with `HEAD /api/uploads/{upload_id}`
4. Finalize with `POST /api/uploads/{upload_id}/complete`
5. Cancel an in-flight upload with `DELETE /api/uploads/{upload_id}` if needed
2026-04-11 20:58:34 +02:00
## API Endpoints
2026-04-22 07:50:41 +02:00
### Create upload session
2026-04-11 20:58:34 +02:00
```http
2026-04-22 07:50:41 +02:00
POST /api/uploads
2026-04-11 20:58:34 +02:00
Content-Type: application/json
{
2026-04-22 07:50:41 +02:00
"filename": "large-video.mp4",
2026-04-11 20:58:34 +02:00
"folder_id": "folder-uuid",
2026-04-22 07:50:41 +02:00
"content_type": "video/mp4",
2026-04-11 20:58:34 +02:00
"total_size": 524288000,
2026-04-22 07:50:41 +02:00
"chunk_size": 8388608
}
```
Typical response:
```json
{
"upload_id" : "uuid" ,
2026-04-11 20:58:34 +02:00
"chunk_size" : 8388608 ,
2026-04-22 07:50:41 +02:00
"total_chunks" : 63 ,
"expires_at" : 86400
2026-04-11 20:58:34 +02:00
}
```
2026-04-22 07:50:41 +02:00
### Upload a chunk
Chunks are sent as raw bytes, not multipart form uploads.
2026-04-11 20:58:34 +02:00
```http
2026-04-22 07:50:41 +02:00
PATCH /api/uploads/{upload_id}?chunk_index=0&checksum=md5-hex
Content-Type: application/octet-stream
Content-MD5: md5-hex
2026-04-11 20:58:34 +02:00
2026-04-22 07:50:41 +02:00
<binary chunk bytes>
2026-04-11 20:58:34 +02:00
```
2026-04-22 07:50:41 +02:00
Notes:
- `chunk_index` is required and zero-based
- `checksum` is optional and can also be supplied with the `Content-MD5` header
- Successful responses include progress headers such as `Upload-Offset` , `Upload-Progress` , and `Upload-Complete`
### Inspect upload status
2026-04-11 20:58:34 +02:00
```http
2026-04-22 07:50:41 +02:00
HEAD /api/uploads/{upload_id}
```
The response includes upload metadata in headers such as:
2026-04-11 20:58:34 +02:00
2026-04-22 07:50:41 +02:00
- `Upload-Offset`
- `Upload-Length`
- `Upload-Progress`
- `Upload-Chunks-Total`
- `Upload-Chunks-Complete`
### Finalize upload
```http
POST /api/uploads/{upload_id}/complete
```
Successful responses return the created file metadata:
```json
2026-04-11 20:58:34 +02:00
{
2026-04-22 07:50:41 +02:00
"file_id" : "uuid" ,
"filename" : "large-video.mp4" ,
"size" : 524288000 ,
"path" : "/Videos/large-video.mp4"
2026-04-11 20:58:34 +02:00
}
```
2026-04-22 07:50:41 +02:00
### Cancel upload
```http
DELETE /api/uploads/{upload_id}
```
This removes the in-progress session and temporary chunk data.
## Validation Rules
2026-04-11 20:58:34 +02:00
2026-04-22 07:50:41 +02:00
- `filename` is required
- `total_size` must be greater than zero
- `chunk_size` must be at least 1 MB when provided
- Storage quota checks can reject the session before upload starts
2026-04-11 20:58:34 +02:00
2026-04-22 07:50:41 +02:00
## Frontend Behavior
2026-04-11 20:58:34 +02:00
2026-04-22 07:50:41 +02:00
The OxiCloud web UI can switch to chunked uploads for larger files, track aggregate progress, and retry individual chunks without restarting the full transfer.