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.upload(imageData.body!, {
      filename: 'photo.jpg',
      metadata: { source: 'example' },
    });

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

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

    // Get image metadata
    const metadata = await env.IMAGES.get(uploaded.id);
    console.log('Got:', metadata?.filename);
    
    // Delete image
    const deleted = await env.IMAGES.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
  • Suggestions on naming and typing decisions very welcome, we're currently not doing much to disambiguate between image transformations and hosted images - perhaps we can do better here?

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

CodSpeed Performance Report

Merging this PR will not alter performance

Comparing mglewis:mattl/images-binding-rpc-support (af8444f) with main (02cf171)

Summary

✅ 68 untouched benchmarks
⏩ 129 skipped benchmarks1

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