Skip to content

feat: parametrise chunked uploads endpoint urls (box/box-openapi#444) #302

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .codegen.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{ "engineHash": "525674e", "specHash": "e50af18", "version": "1.3.0" }
{ "engineHash": "d1cb68d", "specHash": "9919482", "version": "1.3.0" }
250 changes: 221 additions & 29 deletions docs/chunkedUploads.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@ This is a manager for chunked uploads (allowed for files at least 20MB).

- [Create upload session](#create-upload-session)
- [Create upload session for existing file](#create-upload-session-for-existing-file)
- [Get upload session by URL](#get-upload-session-by-url)
- [Get upload session](#get-upload-session)
- [Upload part of file by URL](#upload-part-of-file-by-url)
- [Upload part of file](#upload-part-of-file)
- [Remove upload session by URL](#remove-upload-session-by-url)
- [Remove upload session](#remove-upload-session)
- [List parts by URL](#list-parts-by-url)
- [List parts](#list-parts)
- [Commit upload session by URL](#commit-upload-session-by-url)
- [Commit upload session](#commit-upload-session)
- [Upload big file](#upload-big-file)

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

```ts
await this.createFileUploadSession(
{
fileName: fileName,
fileSize: fileSize,
folderId: parentFolderId,
} satisfies CreateFileUploadSessionRequestBody,
{
headers: new CreateFileUploadSessionHeaders({}),
cancellationToken: cancellationToken,
} satisfies CreateFileUploadSessionOptionalsInput
);
await client.chunkedUploads.createFileUploadSession({
fileName: fileName,
fileSize: fileSize,
folderId: parentFolderId,
} satisfies CreateFileUploadSessionRequestBody);
```

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

Returns a new upload session.

## Get upload session by URL

Return information about an upload session.

The actual endpoint URL is returned by the [`Create upload session`](e://post-files-upload-sessions) endpoint.

This operation is performed by calling function `getFileUploadSessionByUrl`.

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

<!-- sample get_files_upload_sessions_id -->

```ts
await client.chunkedUploads.getFileUploadSessionByUrl(statusUrl);
```

### Arguments

- url `string`
- URL of getFileUploadSessionById method
- optionalsInput `GetFileUploadSessionByUrlOptionalsInput`
-

### Returns

This function returns a value of type `UploadSession`.

Returns an upload session object.

## Get upload session

Return information about an upload session.

The actual endpoint URL is returned by the [`Create upload session`](e://post-files-upload-sessions) endpoint.

This operation is performed by calling function `getFileUploadSessionById`.

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

_Currently we don't have an example for calling `getFileUploadSessionById` in integration tests_
<!-- sample get_files_upload_sessions_id -->

```ts
await client.chunkedUploads.getFileUploadSessionById(uploadSessionId);
```

### Arguments

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

Returns an upload session object.

## Upload part of file by URL

Uploads a chunk of a file for an upload session.

The actual endpoint URL is returned by the [`Create upload session`](e://post-files-upload-sessions)
and [`Get upload session`](e://get-files-upload-sessions-id) endpoints.

This operation is performed by calling function `uploadFilePartByUrl`.

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

<!-- sample put_files_upload_sessions_id -->

```ts
await client.chunkedUploads.uploadFilePartByUrl(
acc.uploadPartUrl,
generateByteStreamFromBuffer(chunkBuffer),
{
digest: digest,
contentRange: contentRange,
} satisfies UploadFilePartByUrlHeadersInput
);
```

### Arguments

- url `string`
- URL of uploadFilePart method
- requestBody `ByteStream`
- Request body of uploadFilePart method
- headersInput `UploadFilePartByUrlHeadersInput`
- Headers of uploadFilePart method
- optionalsInput `UploadFilePartByUrlOptionalsInput`
-

### Returns

This function returns a value of type `UploadedPart`.

Chunk has been uploaded successfully.

## Upload part of file

Updates a chunk of an upload session for a file.
Uploads a chunk of a file for an upload session.

The actual endpoint URL is returned by the [`Create upload session`](e://post-files-upload-sessions)
and [`Get upload session`](e://get-files-upload-sessions-id) endpoints.

This operation is performed by calling function `uploadFilePart`.

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

```ts
await this.uploadFilePart(
await client.chunkedUploads.uploadFilePart(
acc.uploadSessionId,
generateByteStreamFromBuffer(chunkBuffer),
{
Expand All @@ -138,18 +218,59 @@ This function returns a value of type `UploadedPart`.

Chunk has been uploaded successfully.

## Remove upload session by URL

Abort an upload session and discard all data uploaded.

This cannot be reversed.

The actual endpoint URL is returned by the [`Create upload session`](e://post-files-upload-sessions)
and [`Get upload session`](e://get-files-upload-sessions-id) endpoints.

This operation is performed by calling function `deleteFileUploadSessionByUrl`.

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

<!-- sample delete_files_upload_sessions_id -->

```ts
await client.chunkedUploads.deleteFileUploadSessionByUrl(abortUrl);
```

### Arguments

- url `string`
- URL of deleteFileUploadSessionById method
- optionalsInput `DeleteFileUploadSessionByUrlOptionalsInput`
-

### Returns

This function returns a value of type `undefined`.

A blank response is returned if the session was
successfully aborted.

## Remove upload session

Abort an upload session and discard all data uploaded.

This cannot be reversed.

The actual endpoint URL is returned by the [`Create upload session`](e://post-files-upload-sessions)
and [`Get upload session`](e://get-files-upload-sessions-id) endpoints.

This operation is performed by calling function `deleteFileUploadSessionById`.

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

_Currently we don't have an example for calling `deleteFileUploadSessionById` in integration tests_
<!-- sample delete_files_upload_sessions_id -->

```ts
await client.chunkedUploads.deleteFileUploadSessionById(uploadSessionId);
```

### Arguments

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

## List parts by URL

Return a list of the chunks uploaded to the upload session so far.

The actual endpoint URL is returned by the [`Create upload session`](e://post-files-upload-sessions)
and [`Get upload session`](e://get-files-upload-sessions-id) endpoints.

This operation is performed by calling function `getFileUploadSessionPartsByUrl`.

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

<!-- sample get_files_upload_sessions_id_parts -->

```ts
await client.chunkedUploads.getFileUploadSessionPartsByUrl(listPartsUrl);
```

### Arguments

- url `string`
- URL of getFileUploadSessionParts method
- optionalsInput `GetFileUploadSessionPartsByUrlOptionalsInput`
-

### Returns

This function returns a value of type `UploadParts`.

Returns a list of parts that have been uploaded.

## List parts

Return a list of the chunks uploaded to the upload
session so far.
Return a list of the chunks uploaded to the upload session so far.

The actual endpoint URL is returned by the [`Create upload session`](e://post-files-upload-sessions)
and [`Get upload session`](e://get-files-upload-sessions-id) endpoints.

This operation is performed by calling function `getFileUploadSessionParts`.

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

```ts
await this.getFileUploadSessionParts(uploadSessionId, {
queryParams: {} satisfies GetFileUploadSessionPartsQueryParams,
headers: new GetFileUploadSessionPartsHeaders({}),
cancellationToken: cancellationToken,
} satisfies GetFileUploadSessionPartsOptionalsInput);
await client.chunkedUploads.getFileUploadSessionParts(uploadSessionId);
```

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

Returns a list of parts that have been uploaded.

## Commit upload session by URL

Close an upload session and create a file from the uploaded chunks.

The actual endpoint URL is returned by the [`Create upload session`](e://post-files-upload-sessions)
and [`Get upload session`](e://get-files-upload-sessions-id) endpoints.

This operation is performed by calling function `createFileUploadSessionCommitByUrl`.

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

<!-- sample post_files_upload_sessions_id_commit -->

```ts
await client.chunkedUploads.createFileUploadSessionCommitByUrl(
commitUrl,
{ parts: parts } satisfies CreateFileUploadSessionCommitByUrlRequestBody,
{ digest: digest } satisfies CreateFileUploadSessionCommitByUrlHeadersInput
);
```

### Arguments

- url `string`
- URL of createFileUploadSessionCommit method
- requestBody `CreateFileUploadSessionCommitByUrlRequestBody`
- Request body of createFileUploadSessionCommit method
- headersInput `CreateFileUploadSessionCommitByUrlHeadersInput`
- Headers of createFileUploadSessionCommit method
- optionalsInput `CreateFileUploadSessionCommitByUrlOptionalsInput`
-

### Returns

This function returns a value of type `Files`.

Returns the file object in a list.Returns when all chunks have been uploaded but not yet processed.

Inspect the upload session to get more information about the
progress of processing the chunks, then retry committing the file
when all chunks have processed.

## Commit upload session

Close an upload session and create a file from the
uploaded chunks.
Close an upload session and create a file from the uploaded chunks.

The actual endpoint URL is returned by the [`Create upload session`](e://post-files-upload-sessions)
and [`Get upload session`](e://get-files-upload-sessions-id) endpoints.

This operation is performed by calling function `createFileUploadSessionCommit`.

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

```ts
await this.createFileUploadSessionCommit(
await client.chunkedUploads.createFileUploadSessionCommit(
uploadSessionId,
{ parts: parts } satisfies CreateFileUploadSessionCommitRequestBody,
{ digest: digest } satisfies CreateFileUploadSessionCommitHeadersInput,
{
cancellationToken: cancellationToken,
} satisfies CreateFileUploadSessionCommitOptionalsInput
{ digest: digest } satisfies CreateFileUploadSessionCommitHeadersInput
);
```

Expand Down
Loading
Loading