Skip to content

feat(Gax): support chunkSize on resume and surface actual chunk size - #9626

Open
bshaffer wants to merge 1 commit into
mainfrom
scotty-chunk-size-resume
Open

bshaffer wants to merge 1 commit into
mainfrom
scotty-chunk-size-resume

Conversation

@bshaffer

@bshaffer bshaffer commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Updates Resumable Uploads to allow specifying a chunkSize when resuming an upload, and exposes getter/setter methods to access the actual/negotiated chunk size.

  1. Pass chunkSize on resume: Users can now pass chunkSize in $optionalArgs to resumeUpload() (or via startResumableUploadCall), or pass it directly into $upload->startUpload($stream, ['chunkSize' => ...]).
  2. Access the actual chunk size: Added getChunkSize(): ?int and setChunkSize(int $chunkSize): void on ResumableUpload. If the server responds with a chunk granularity (X-Goog-Upload-Chunk-Granularity), the chunk size is adjusted down to the closest multiple and surfaced on the upload object.
  3. Resuming documentation: Added docblock notes recommending that streams are rewound to offset 0 before resuming, so unconfirmed chunks can be re-read if needed.

Example usage:

// 1. Specify chunk size when resuming
$resumableUpload = $client->resumeUpload($uploadUrl, 'createUpload', [
    'chunkSize' => 5 * 1024 * 1024, // 5 MB chunks
]);

// 2. Or retrieve the actual chunk size used/negotiated
$actualChunkSize = $resumableUpload->getChunkSize();

// 3. Start/resume upload
$response = $resumableUpload->startUpload($dataStream);

@viacheslav-rostovtsev viacheslav-rostovtsev left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SGTM!

@bshaffer
bshaffer force-pushed the scotty-chunk-size-resume branch from 49604a2 to 395374a Compare September 15, 2026 02:17
@bshaffer
bshaffer marked this pull request as ready for review September 15, 2026 02:20
@bshaffer
bshaffer requested a review from a team as a code owner September 15, 2026 02:20
@bshaffer bshaffer added the next release PRs to be included in the next release label Sep 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

next release PRs to be included in the next release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants