Skip to content

Conversation

@mglewis
Copy link

@mglewis mglewis commented Jan 16, 2026

Currently the Images Binding only supports info and transform operations. This PR introduces support for the following Hosted Images endpoints that are already available via the images api:

The images binding has recently been switched to a direct binding, so whilst info and transform are still handled by fetcher.fetch the new endpoints for managing Hosted Images pass through via RPC.

Sample implementation

Once released, we'd expect users to be able to write worker code that looks something like

export default {
  async fetch(request: Request, env: Env): Promise<Response> {
    // Upload an image
    const imageData = await fetch('https://example.com/photo.jpg');
    const uploaded = await env.IMAGES.hosted.upload(imageData.body!, {
      filename: 'photo.jpg',
      metadata: { source: 'example' },
    });

    // List images
    const list = await env.IMAGES.hosted.list({ limit: 10 });
    console.log('Images:', list.images.length, 'Complete:', list.listComplete);

    // Update image
    const updated = await env.IMAGES.hosted.update(uploaded.id, {
      metadata: { source: 'example', edited: true },
    });

    // Get image metadata
    const metadata = await env.IMAGES.hosted.details(uploaded.id);
    console.log('Got:', metadata?.filename);
    
    // Delete image
    const deleted = await env.IMAGES.hosted.delete(uploaded.id);
    console.log('Deleted:', deleted);
    return new Response('Done!');
  },
};

Reviewer Considerations

  • This change is coupled tightly with our upstream images api change. A decision has been made to try and keep as much logic in the upstream as possible with the only new upload method having having a non trivial implementation (to leverage workerd's base64 decoding support)
  • In the future we may also want to do away with images-api.ts in its entirety and move the existing transformation logic into our upstream images api
  • After discussion with the team we've opted to go for namespacing the new methods so that they are accessed as follows env.IMAGES.hosted.list(). We are hopeful that will more clearly disambiguate their function to users and give us more flexibility on the addition of new methods to the binding in the future.

Next Steps

  • We still need to make the edgeworker config service inject the accountId into ctx.props
  • Workers sdk / wrangler / miniflare support

@github-actions
Copy link

github-actions bot commented Jan 16, 2026

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@mglewis
Copy link
Author

mglewis commented Jan 16, 2026

I have read the CLA Document and I hereby sign the CLA

@codspeed-hq
Copy link

codspeed-hq bot commented Jan 16, 2026

Merging this PR will not alter performance

✅ 70 untouched benchmarks
⏩ 129 skipped benchmarks1


Comparing mglewis:mattl/images-binding-rpc-support (826c28b) with main (6ff050c)

Open in CodSpeed

Footnotes

  1. 129 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@mglewis mglewis force-pushed the mattl/images-binding-rpc-support branch from a721698 to cb83759 Compare January 16, 2026 13:14
github-actions bot added a commit that referenced this pull request Jan 16, 2026
@mglewis mglewis force-pushed the mattl/images-binding-rpc-support branch from af8444f to 826c28b Compare February 11, 2026 21:26
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.

2 participants