Skip to content

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

Draft
falcoagustin wants to merge 2 commits into
mainfrom
falcoagustin/blob-optimize-image
Draft

[blob] Add optimizeImage option to put and new putFromUrl method#1093
falcoagustin wants to merge 2 commits into
mainfrom
falcoagustin/blob-optimize-image

Conversation

@falcoagustin

@falcoagustin falcoagustin commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator

What

SDK support for storing optimized images:

  • put(pathname, body, { optimizeImage })POST /put-optimized (body streamed through the optimizer, optimized output stored)
  • putFromUrl(pathname, url, { access, optimizeImage })POST /put-from-url (optimizer fetches the source URL server-side)
const result = await put('avatars/foo.webp', body, {
  access: 'public',
  optimizeImage: { width: 128, quality: 75, format: 'webp' },
});

const result = await putFromUrl('avatars/foo.webp', 'https://example.com/photo.jpg', {
  access: 'public',
  optimizeImage: { width: 128, quality: 75, format: 'webp' },
});

Notes

  • optimizeImage: { width: number, quality?: number (default 75), format?: 'jpeg' | 'png' | 'webp' | 'avif' } — short format names map to MIME types on the wire; all validation is server-side.
  • OIDC-only (the API rejects other token types with a clear 403).
  • optimizeImage + multipart throws.
  • Stored contentType comes from the optimizer output, not the pathname extension.
  • Requires the corresponding Blob API support to be deployed first; do not merge until it is.
  • Tests cover both new paths (put-from-url.node.test.ts), including ifMatch forwarding and the multipart conflict.

🤖 Generated with Claude Code

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>
@vercel

vercel Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
vercel-storage-next-integration-test-suite Ready Ready Preview Jul 30, 2026 3:15pm

Request Review

@changeset-bot

changeset-bot Bot commented Jul 30, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: b545cca

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@vercel/blob Minor
vercel-storage-integration-test-suite Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant