Skip to content
This repository was archived by the owner on Mar 3, 2026. It is now read-only.

Commit 3acfd5b

Browse files
feat: Expose chunkSize param for CreateResumableUploadOptions (#1754)
* feat: Expose `chunkSize` param for `CreateResumableUploadOptions` * docs: Add documentation for `chunkSize`
1 parent 939ab04 commit 3acfd5b

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

src/file.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ export type PredefinedAcl =
190190
| 'publicRead';
191191

192192
export interface CreateResumableUploadOptions {
193+
chunkSize?: number;
193194
configPath?: string;
194195
metadata?: Metadata;
195196
origin?: string;
@@ -1556,6 +1557,9 @@ class File extends ServiceObject<File> {
15561557
* `options.predefinedAcl = 'publicRead'`)
15571558
* @property {string} [userProject] The ID of the project which will be
15581559
* billed for the request.
1560+
* @property {string} [chunkSize] Create a separate request per chunk. Should
1561+
* be a multiple of 256 KiB (2^18).
1562+
* {@link https://cloud.google.com/storage/docs/performing-resumable-uploads#chunked-upload| We recommend using at least 8 MiB for the chunk size.}
15591563
*/
15601564
/**
15611565
* Create a unique resumable upload session URI. This is the first step when
@@ -3980,6 +3984,7 @@ class File extends ServiceObject<File> {
39803984
userProject: options.userProject || this.userProject,
39813985
retryOptions: retryOptions,
39823986
params: options?.preconditionOpts || this.instancePreconditionOpts,
3987+
chunkSize: options?.chunkSize,
39833988
});
39843989

39853990
uploadStream

test/file.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4762,6 +4762,7 @@ describe('File', () => {
47624762
predefinedAcl: 'allUsers',
47634763
uri: 'http://resumable-uri',
47644764
userProject: 'user-project-id',
4765+
chunkSize: 262144, // 256 KiB
47654766
};
47664767

47674768
file.generation = 3;
@@ -4815,6 +4816,7 @@ describe('File', () => {
48154816
assert.strictEqual(opts.userProject, options.userProject);
48164817
assert.strictEqual(opts.retryOptions, storage.retryOptions);
48174818
assert.strictEqual(opts.params, storage.preconditionOpts);
4819+
assert.strictEqual(opts.chunkSize, options.chunkSize);
48184820

48194821
setImmediate(done);
48204822
return new PassThrough();

0 commit comments

Comments
 (0)