You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: MULTIPART_UPLOAD.md
+14-10Lines changed: 14 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,13 +8,17 @@ The server provides three endpoints:
8
8
- Upload a single part: POST /videos/multiparts/:uploadId/parts/:partIndex
9
9
- Check upload status: GET /videos/multiparts/:uploadId
10
10
11
-
Security: All multi-part endpoints require the `token` query parameter matching the `APP_TOKEN` configuration value.
12
-
Uploading must also be enabled via `APP_UPLOADING_ENABLED=true` and S3 must be configured.
13
-
Redis is required for upload tracking when using multi-part uploads.
11
+
Security:
12
+
- The initialization endpoint requires `token` query parameter matching `APP_TOKEN`.
13
+
- Part upload requires `uploadToken` (a unique token generated per upload session, returned by init).
14
+
- Status check requires `token` query parameter matching `APP_TOKEN`.
15
+
- Uploading must be enabled via `APP_UPLOADING_ENABLED=true` and S3 must be configured.
16
+
- Redis is required for upload tracking when using multi-part uploads.
14
17
15
18
## Key concepts
16
19
17
20
- uploadId: A server-generated identifier for the multi-part upload session. Returned by the initialization endpoint.
21
+
- uploadToken: A secure random token generated per upload session. Use this to authenticate part uploads (not APP_TOKEN).
18
22
- parts: The file is split into N parts according to the configured chunk size. Each part has index, offset and size.
19
23
- partIndex: Zero-based index of a part in the upload session.
20
24
- chunkSize: The per-part size in bytes. Default is 80 MB (80 * 1024 * 1024). Can be overridden during init.
@@ -49,6 +53,7 @@ Response (200 OK)
49
53
```json
50
54
{
51
55
"uploadId": "<upload-id>",
56
+
"uploadToken": "<secure-random-token>",
52
57
"location": "videos/user123/my-video.mp4",
53
58
"totalSize": 157286400,
54
59
"chunkSize": 83886080,
@@ -69,26 +74,28 @@ Errors
69
74
70
75
Notes
71
76
- The server computes partsCount = ceil(size / chunkSize) and returns an array of part metadata with offsets and sizes.
77
+
- The server generates a unique `uploadToken` for this session. Save this token - you'll need it to upload parts.
72
78
- Upload tracking is stored in Redis under the key `upload:{uploadId}` and kept until the upload `expiresAt` (or a configured TTL).
73
79
74
80
## 2) Upload a part
75
81
76
82
Endpoint
77
83
```
78
-
POST /videos/multiparts/:uploadId/parts/:partIndex?token={token}
84
+
POST /videos/multiparts/:uploadId/parts/:partIndex?uploadToken={uploadToken}
79
85
```
80
86
81
87
Path parameters
82
88
- uploadId (required) — upload session id returned by init
83
89
- partIndex (required) — zero-based part index to upload
84
90
85
91
Query parameters
86
-
-token (required) — must match `APP_TOKEN`
92
+
-uploadToken (required) — the unique token returned by the init endpoint (NOT APP_TOKEN)
87
93
88
94
Form data
89
95
- video (required) — the multipart `video` field containing raw bytes for this part. The server expects the part size to exactly match the declared size for this part.
90
96
91
97
Behavior
98
+
- The server validates the `uploadToken` against the stored upload session.
92
99
- The server reads the `uploadId` info from Redis, validates the `partIndex` and the part size.
93
100
- The part is stored in S3 under `{location}.part{partIndex}` using the configured S3 client.
0 commit comments