@@ -145,6 +145,30 @@ Use the option `startBody` to add more parameters to the body of this request.
145
145
146
146
The backend should provide a ` session_id ` (to identify the upload) and a ` end_offset ` which is the size of every chunk
147
147
148
+ ##### HTTP start phase example
149
+
150
+ Request body example:
151
+ ```
152
+ {
153
+ "phase": "start",
154
+ "mime_type": "image/png",
155
+ "size": 12669430,
156
+ "name":"hubbleimage1stscihp1809af6400x4800.png"
157
+ }
158
+ ```
159
+
160
+ Response body example:
161
+ ```
162
+ {
163
+ "data": {
164
+ "end_offset": 6291456,
165
+ "session_id": "61db8102-fca6-44ae-81e2-a499d438e7a5"
166
+ },
167
+ "status": "success"
168
+ }
169
+
170
+ ```
171
+
148
172
#### upload
149
173
150
174
In this phase we'll upload every chunk until all of them are uploaded. This step allows some failures in the backend, and will retry up to ` maxRetries ` times.
@@ -153,12 +177,118 @@ We'll send the `session_id`, `start_offset` and `chunk` (the sliced blob - part
153
177
154
178
Use the option ` uploadBody ` to add more parameters to the body of this request.
155
179
180
+ ##### HTTP upload phase example with 3 chunks
181
+
182
+ Request body example - chunk 1 from 3:
183
+ ```
184
+ ------WebKitFormBoundaryuI0uiY8h7MCbcysx
185
+ Content-Disposition: form-data; name="phase"
186
+
187
+ upload
188
+ ------WebKitFormBoundaryuI0uiY8h7MCbcysx
189
+ Content-Disposition: form-data; name="session_id"
190
+
191
+ 61db8102-fca6-44ae-81e2-a499d438e7a5
192
+ ------WebKitFormBoundaryuI0uiY8h7MCbcysx
193
+ Content-Disposition: form-data; name="start_offset"
194
+
195
+ 0
196
+ ------WebKitFormBoundaryuI0uiY8h7MCbcysx
197
+ Content-Disposition: form-data; name="chunk"; filename="blob"
198
+ Content-Type: application/octet-stream
199
+
200
+
201
+ ------WebKitFormBoundaryuI0uiY8h7MCbcysx--
202
+ ```
203
+
204
+ Response body example - chunk 1 from 3:
205
+ ```
206
+ {
207
+ "status": "success"
208
+ }
209
+ ```
210
+
211
+ Request body example - chunk 2 from 3:
212
+ ```
213
+ ------WebKitFormBoundary4cjBupFqrx1SrHoR
214
+ Content-Disposition: form-data; name="phase"
215
+
216
+ upload
217
+ ------WebKitFormBoundary4cjBupFqrx1SrHoR
218
+ Content-Disposition: form-data; name="session_id"
219
+
220
+ 61db8102-fca6-44ae-81e2-a499d438e7a5
221
+ ------WebKitFormBoundary4cjBupFqrx1SrHoR
222
+ Content-Disposition: form-data; name="start_offset"
223
+
224
+ 6291456
225
+ ------WebKitFormBoundary4cjBupFqrx1SrHoR
226
+ Content-Disposition: form-data; name="chunk"; filename="blob"
227
+ Content-Type: application/octet-stream
228
+
229
+
230
+ ------WebKitFormBoundary4cjBupFqrx1SrHoR-
231
+ ```
232
+
233
+ Response body example - chunk 2 from 3:
234
+ ```
235
+ {
236
+ "status": "success"
237
+ }
238
+ ```
239
+
240
+ Request body example - chunk 3 from 3:
241
+ ```
242
+ ------WebKitFormBoundarypWxg4xnB5QBDoFys
243
+ Content-Disposition: form-data; name="phase"
244
+
245
+ upload
246
+ ------WebKitFormBoundarypWxg4xnB5QBDoFys
247
+ Content-Disposition: form-data; name="session_id"
248
+
249
+ 61db8102-fca6-44ae-81e2-a499d438e7a5
250
+ ------WebKitFormBoundarypWxg4xnB5QBDoFys
251
+ Content-Disposition: form-data; name="start_offset"
252
+
253
+ 12582912
254
+ ------WebKitFormBoundarypWxg4xnB5QBDoFys
255
+ Content-Disposition: form-data; name="chunk"; filename="blob"
256
+ Content-Type: application/octet-stream
257
+
258
+
259
+ ------WebKitFormBoundarypWxg4xnB5QBDoFys--
260
+ ```
261
+
262
+ Response body example - chunk 1 from 3:
263
+ ```
264
+ {
265
+ "status": "success"
266
+ }
267
+ ```
268
+
156
269
#### finish
157
270
158
271
In this phase we tell the backend that there are no more chunks to upload, so it can wrap everything. We send the ` session_id ` in this phase.
159
272
160
273
Use the option ` finishBody ` to add more parameters to the body of this request.
161
274
275
+ ##### HTTP finish phase example
276
+
277
+ Request body example:
278
+ ```
279
+ {
280
+ "phase": "finish",
281
+ "session_id": "61db8102-fca6-44ae-81e2-a499d438e7a5"
282
+ }
283
+ ```
284
+
285
+ Response body example:
286
+ ```
287
+ {
288
+ "status": "success"
289
+ }
290
+ ```
291
+
162
292
#### Example
163
293
164
294
In the following example we are going to add ` Chunk Upload Functionality ` . This component will use ` Chunk Upload ` when the size of the file is > ` 1MB ` , it will behave as the ` Simple example ` when the size of the file is lower.
0 commit comments