Skip to content

r2 objects put: no way to set Cache-Control (and other object headers Wrangler supports) #786

Backlog

Description

@amiranvarov

cf r2 objects put can't set Cache-Control on an uploaded object. wrangler r2 object put --remote can, and both call the same endpoint (PUT /accounts/{account_id}/r2/buckets/{bucket_name}/objects/{object_key}).

Versions: cf 1.0.0-rc.5 (latest on npm), wrangler 4.145.0, macOS.

Reproduce:

cf r2 objects put releases/app/latest.zip --bucket-name my-bucket --file ./latest.zip --content-type application/zip --cache-control no-cache

Result: Unknown arguments: cache-control, cacheControl

Wrangler sets this header on the same endpoint:

wrangler r2 object put --remote my-bucket/releases/app/latest.zip --file ./latest.zip --content-type application/zip --cache-control no-cache

Cause: the published OpenAPI description for r2-put-object lists only these headers: Content-Type, Content-Length, cf-r2-jurisdiction and cf-r2-storage-class. Wrangler also sends Cache-Control, Content-Disposition, Content-Encoding, Content-Language and Expires, and the API accepts them. Because cf generates its flags from the schema, those headers can't be set.

Why it matters: objects such as a "latest" download alias or an update feed need Cache-Control: no-cache so clients don't get stale copies after a release. Without it, uploads like these can't move from Wrangler to cf.

Request: add these headers to the r2-put-object schema, or give cf a way to pass extra request headers.

Possibly related: cf r2 objects put encodes the object key with encodeURIComponent, so / is sent as %2F. The command's own help says slashes "MUST be sent literally and MUST NOT be percent-encoded". I haven't checked whether the API then stores a different key.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions