Skip to content

Commit 293a6e9

Browse files
feat: parametrise chunked uploads endpoint urls (box/box-openapi#444) (#302)
1 parent db3a2b5 commit 293a6e9

File tree

5 files changed

+1321
-136
lines changed

5 files changed

+1321
-136
lines changed

.codegen.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{ "engineHash": "525674e", "specHash": "e50af18", "version": "1.3.0" }
1+
{ "engineHash": "d1cb68d", "specHash": "9919482", "version": "1.3.0" }

docs/chunkedUploads.md

+221-29
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,15 @@ This is a manager for chunked uploads (allowed for files at least 20MB).
44

55
- [Create upload session](#create-upload-session)
66
- [Create upload session for existing file](#create-upload-session-for-existing-file)
7+
- [Get upload session by URL](#get-upload-session-by-url)
78
- [Get upload session](#get-upload-session)
9+
- [Upload part of file by URL](#upload-part-of-file-by-url)
810
- [Upload part of file](#upload-part-of-file)
11+
- [Remove upload session by URL](#remove-upload-session-by-url)
912
- [Remove upload session](#remove-upload-session)
13+
- [List parts by URL](#list-parts-by-url)
1014
- [List parts](#list-parts)
15+
- [Commit upload session by URL](#commit-upload-session-by-url)
1116
- [Commit upload session](#commit-upload-session)
1217
- [Upload big file](#upload-big-file)
1318

@@ -23,17 +28,11 @@ See the endpoint docs at
2328
<!-- sample post_files_upload_sessions -->
2429

2530
```ts
26-
await this.createFileUploadSession(
27-
{
28-
fileName: fileName,
29-
fileSize: fileSize,
30-
folderId: parentFolderId,
31-
} satisfies CreateFileUploadSessionRequestBody,
32-
{
33-
headers: new CreateFileUploadSessionHeaders({}),
34-
cancellationToken: cancellationToken,
35-
} satisfies CreateFileUploadSessionOptionalsInput
36-
);
31+
await client.chunkedUploads.createFileUploadSession({
32+
fileName: fileName,
33+
fileSize: fileSize,
34+
folderId: parentFolderId,
35+
} satisfies CreateFileUploadSessionRequestBody);
3736
```
3837

3938
### Arguments
@@ -75,16 +74,52 @@ This function returns a value of type `UploadSession`.
7574

7675
Returns a new upload session.
7776

77+
## Get upload session by URL
78+
79+
Return information about an upload session.
80+
81+
The actual endpoint URL is returned by the [`Create upload session`](e://post-files-upload-sessions) endpoint.
82+
83+
This operation is performed by calling function `getFileUploadSessionByUrl`.
84+
85+
See the endpoint docs at
86+
[API Reference](https://developer.box.com/reference/get-files-upload-sessions-id/).
87+
88+
<!-- sample get_files_upload_sessions_id -->
89+
90+
```ts
91+
await client.chunkedUploads.getFileUploadSessionByUrl(statusUrl);
92+
```
93+
94+
### Arguments
95+
96+
- url `string`
97+
- URL of getFileUploadSessionById method
98+
- optionalsInput `GetFileUploadSessionByUrlOptionalsInput`
99+
-
100+
101+
### Returns
102+
103+
This function returns a value of type `UploadSession`.
104+
105+
Returns an upload session object.
106+
78107
## Get upload session
79108

80109
Return information about an upload session.
81110

111+
The actual endpoint URL is returned by the [`Create upload session`](e://post-files-upload-sessions) endpoint.
112+
82113
This operation is performed by calling function `getFileUploadSessionById`.
83114

84115
See the endpoint docs at
85116
[API Reference](https://developer.box.com/reference/get-files-upload-sessions-id/).
86117

87-
_Currently we don't have an example for calling `getFileUploadSessionById` in integration tests_
118+
<!-- sample get_files_upload_sessions_id -->
119+
120+
```ts
121+
await client.chunkedUploads.getFileUploadSessionById(uploadSessionId);
122+
```
88123

89124
### Arguments
90125

@@ -99,9 +134,54 @@ This function returns a value of type `UploadSession`.
99134

100135
Returns an upload session object.
101136

137+
## Upload part of file by URL
138+
139+
Uploads a chunk of a file for an upload session.
140+
141+
The actual endpoint URL is returned by the [`Create upload session`](e://post-files-upload-sessions)
142+
and [`Get upload session`](e://get-files-upload-sessions-id) endpoints.
143+
144+
This operation is performed by calling function `uploadFilePartByUrl`.
145+
146+
See the endpoint docs at
147+
[API Reference](https://developer.box.com/reference/put-files-upload-sessions-id/).
148+
149+
<!-- sample put_files_upload_sessions_id -->
150+
151+
```ts
152+
await client.chunkedUploads.uploadFilePartByUrl(
153+
acc.uploadPartUrl,
154+
generateByteStreamFromBuffer(chunkBuffer),
155+
{
156+
digest: digest,
157+
contentRange: contentRange,
158+
} satisfies UploadFilePartByUrlHeadersInput
159+
);
160+
```
161+
162+
### Arguments
163+
164+
- url `string`
165+
- URL of uploadFilePart method
166+
- requestBody `ByteStream`
167+
- Request body of uploadFilePart method
168+
- headersInput `UploadFilePartByUrlHeadersInput`
169+
- Headers of uploadFilePart method
170+
- optionalsInput `UploadFilePartByUrlOptionalsInput`
171+
-
172+
173+
### Returns
174+
175+
This function returns a value of type `UploadedPart`.
176+
177+
Chunk has been uploaded successfully.
178+
102179
## Upload part of file
103180

104-
Updates a chunk of an upload session for a file.
181+
Uploads a chunk of a file for an upload session.
182+
183+
The actual endpoint URL is returned by the [`Create upload session`](e://post-files-upload-sessions)
184+
and [`Get upload session`](e://get-files-upload-sessions-id) endpoints.
105185

106186
This operation is performed by calling function `uploadFilePart`.
107187

@@ -111,7 +191,7 @@ See the endpoint docs at
111191
<!-- sample put_files_upload_sessions_id -->
112192

113193
```ts
114-
await this.uploadFilePart(
194+
await client.chunkedUploads.uploadFilePart(
115195
acc.uploadSessionId,
116196
generateByteStreamFromBuffer(chunkBuffer),
117197
{
@@ -138,18 +218,59 @@ This function returns a value of type `UploadedPart`.
138218

139219
Chunk has been uploaded successfully.
140220

221+
## Remove upload session by URL
222+
223+
Abort an upload session and discard all data uploaded.
224+
225+
This cannot be reversed.
226+
227+
The actual endpoint URL is returned by the [`Create upload session`](e://post-files-upload-sessions)
228+
and [`Get upload session`](e://get-files-upload-sessions-id) endpoints.
229+
230+
This operation is performed by calling function `deleteFileUploadSessionByUrl`.
231+
232+
See the endpoint docs at
233+
[API Reference](https://developer.box.com/reference/delete-files-upload-sessions-id/).
234+
235+
<!-- sample delete_files_upload_sessions_id -->
236+
237+
```ts
238+
await client.chunkedUploads.deleteFileUploadSessionByUrl(abortUrl);
239+
```
240+
241+
### Arguments
242+
243+
- url `string`
244+
- URL of deleteFileUploadSessionById method
245+
- optionalsInput `DeleteFileUploadSessionByUrlOptionalsInput`
246+
-
247+
248+
### Returns
249+
250+
This function returns a value of type `undefined`.
251+
252+
A blank response is returned if the session was
253+
successfully aborted.
254+
141255
## Remove upload session
142256

143257
Abort an upload session and discard all data uploaded.
144258

145259
This cannot be reversed.
146260

261+
The actual endpoint URL is returned by the [`Create upload session`](e://post-files-upload-sessions)
262+
and [`Get upload session`](e://get-files-upload-sessions-id) endpoints.
263+
147264
This operation is performed by calling function `deleteFileUploadSessionById`.
148265

149266
See the endpoint docs at
150267
[API Reference](https://developer.box.com/reference/delete-files-upload-sessions-id/).
151268

152-
_Currently we don't have an example for calling `deleteFileUploadSessionById` in integration tests_
269+
<!-- sample delete_files_upload_sessions_id -->
270+
271+
```ts
272+
await client.chunkedUploads.deleteFileUploadSessionById(uploadSessionId);
273+
```
153274

154275
### Arguments
155276

@@ -165,10 +286,43 @@ This function returns a value of type `undefined`.
165286
A blank response is returned if the session was
166287
successfully aborted.
167288

289+
## List parts by URL
290+
291+
Return a list of the chunks uploaded to the upload session so far.
292+
293+
The actual endpoint URL is returned by the [`Create upload session`](e://post-files-upload-sessions)
294+
and [`Get upload session`](e://get-files-upload-sessions-id) endpoints.
295+
296+
This operation is performed by calling function `getFileUploadSessionPartsByUrl`.
297+
298+
See the endpoint docs at
299+
[API Reference](https://developer.box.com/reference/get-files-upload-sessions-id-parts/).
300+
301+
<!-- sample get_files_upload_sessions_id_parts -->
302+
303+
```ts
304+
await client.chunkedUploads.getFileUploadSessionPartsByUrl(listPartsUrl);
305+
```
306+
307+
### Arguments
308+
309+
- url `string`
310+
- URL of getFileUploadSessionParts method
311+
- optionalsInput `GetFileUploadSessionPartsByUrlOptionalsInput`
312+
-
313+
314+
### Returns
315+
316+
This function returns a value of type `UploadParts`.
317+
318+
Returns a list of parts that have been uploaded.
319+
168320
## List parts
169321

170-
Return a list of the chunks uploaded to the upload
171-
session so far.
322+
Return a list of the chunks uploaded to the upload session so far.
323+
324+
The actual endpoint URL is returned by the [`Create upload session`](e://post-files-upload-sessions)
325+
and [`Get upload session`](e://get-files-upload-sessions-id) endpoints.
172326

173327
This operation is performed by calling function `getFileUploadSessionParts`.
174328

@@ -178,11 +332,7 @@ See the endpoint docs at
178332
<!-- sample get_files_upload_sessions_id_parts -->
179333

180334
```ts
181-
await this.getFileUploadSessionParts(uploadSessionId, {
182-
queryParams: {} satisfies GetFileUploadSessionPartsQueryParams,
183-
headers: new GetFileUploadSessionPartsHeaders({}),
184-
cancellationToken: cancellationToken,
185-
} satisfies GetFileUploadSessionPartsOptionalsInput);
335+
await client.chunkedUploads.getFileUploadSessionParts(uploadSessionId);
186336
```
187337

188338
### Arguments
@@ -198,10 +348,55 @@ This function returns a value of type `UploadParts`.
198348

199349
Returns a list of parts that have been uploaded.
200350

351+
## Commit upload session by URL
352+
353+
Close an upload session and create a file from the uploaded chunks.
354+
355+
The actual endpoint URL is returned by the [`Create upload session`](e://post-files-upload-sessions)
356+
and [`Get upload session`](e://get-files-upload-sessions-id) endpoints.
357+
358+
This operation is performed by calling function `createFileUploadSessionCommitByUrl`.
359+
360+
See the endpoint docs at
361+
[API Reference](https://developer.box.com/reference/post-files-upload-sessions-id-commit/).
362+
363+
<!-- sample post_files_upload_sessions_id_commit -->
364+
365+
```ts
366+
await client.chunkedUploads.createFileUploadSessionCommitByUrl(
367+
commitUrl,
368+
{ parts: parts } satisfies CreateFileUploadSessionCommitByUrlRequestBody,
369+
{ digest: digest } satisfies CreateFileUploadSessionCommitByUrlHeadersInput
370+
);
371+
```
372+
373+
### Arguments
374+
375+
- url `string`
376+
- URL of createFileUploadSessionCommit method
377+
- requestBody `CreateFileUploadSessionCommitByUrlRequestBody`
378+
- Request body of createFileUploadSessionCommit method
379+
- headersInput `CreateFileUploadSessionCommitByUrlHeadersInput`
380+
- Headers of createFileUploadSessionCommit method
381+
- optionalsInput `CreateFileUploadSessionCommitByUrlOptionalsInput`
382+
-
383+
384+
### Returns
385+
386+
This function returns a value of type `Files`.
387+
388+
Returns the file object in a list.Returns when all chunks have been uploaded but not yet processed.
389+
390+
Inspect the upload session to get more information about the
391+
progress of processing the chunks, then retry committing the file
392+
when all chunks have processed.
393+
201394
## Commit upload session
202395

203-
Close an upload session and create a file from the
204-
uploaded chunks.
396+
Close an upload session and create a file from the uploaded chunks.
397+
398+
The actual endpoint URL is returned by the [`Create upload session`](e://post-files-upload-sessions)
399+
and [`Get upload session`](e://get-files-upload-sessions-id) endpoints.
205400

206401
This operation is performed by calling function `createFileUploadSessionCommit`.
207402

@@ -211,13 +406,10 @@ See the endpoint docs at
211406
<!-- sample post_files_upload_sessions_id_commit -->
212407

213408
```ts
214-
await this.createFileUploadSessionCommit(
409+
await client.chunkedUploads.createFileUploadSessionCommit(
215410
uploadSessionId,
216411
{ parts: parts } satisfies CreateFileUploadSessionCommitRequestBody,
217-
{ digest: digest } satisfies CreateFileUploadSessionCommitHeadersInput,
218-
{
219-
cancellationToken: cancellationToken,
220-
} satisfies CreateFileUploadSessionCommitOptionalsInput
412+
{ digest: digest } satisfies CreateFileUploadSessionCommitHeadersInput
221413
);
222414
```
223415

0 commit comments

Comments
 (0)