Conditional PUT not supported in R2?

Hi, the Cloudflare R2 bindings as of compatibility_date = "2022-05-31" don’t seem to support conditional PUTs (say using If-Match). Is that by design?

If yes, what’s the recommended way to avoid conflicting writes to the same R2 object?

If no, how do I go about doing it?

I’m not aware of the .put() Workers binding for R2 ever supporting conditionals - it’s not documented in https://developers.cloudflare.com/r2/runtime-apis/#r2putoptions

Are you saying this used to be supported in the past?

I’'m not saying that. I’m asking if this is

  1. Supported in the storage backend but not exposed in the API binding, i.e. an API oversight, or
  2. Not expected to be supported, as a conscious design choice.

If it’s the latter, what is the recommended way to prevent race conditions in concurrent read-writes to an R2 object?

It’s in there now although the docs are a bit stale at the moment. Basically, if the S3 interface supports something but bindings don’t, it’s highly likely we’ll get around to it eventually.

2 Likes

Awesome, thanks!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.