SIGN IN SIGN UP

[blob] Add optimizeImage option to put and new putFromUrl method (#1093)

* [blob] Add optimizeImage option to put and new putFromUrl method

Both call the new blob API endpoints (POST /put-optimized and
POST /put-from-url) that optimize the image through Vercel Image
Optimization before storing it. OIDC-only.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* [blob] Fix putFromUrl dropping ifMatch and reuse shared put validation

putFromUrl now goes through createPutOptions/createPutHeaders like every
other put-style method, which forwards x-if-match (with the implicit
allowOverwrite behavior) instead of silently dropping it. contentType is
omitted from PutFromUrlCommandOptions since the stored content type always
comes from the optimizer output. Adds tests for put({optimizeImage}) and
putFromUrl.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* [blob] Validate optimizeImage options and source content type client-side

Bad values (quality > 100, fractional width, unknown format) and clearly
non-image sources now fail fast with a descriptive BlobError instead of a
round trip that bills nothing but confuses with a server error. Only
explicit signals (contentType option, Blob/File type) are inspected; the
server still detects the actual format from the bytes.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* [blob] Raise optimizeImage.width max to 8192 to match image optimization limits

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
A
Agustin Falco committed
ad5a134e05ecee6cbffd7fab5dce8b4d075fe71f
Parent: 9f1c171
Committed by GitHub <noreply@github.com> on 8/4/2026, 8:23:47 PM