With R2, there exists “Object Read & Write” API Token permission for a bucket. I would expect that the user of this token would be able to use the HeadBucket API. Unfortunately, that’s not possible. If I (or anyone using the token), can write and read in the bucket, we should be able to Head the bucket.
It’s important to determine if the bucket exists before trying to write an object, or to determine if it’s possible to write an object, otherwise we could skip trying altogether. Also, if writing or reading isn’t succeeding, why isn’t it succeeding, is it because the bucket doesn’t exist? These are important questions that somebody with the ‘Object Read & Write’ token should be able to ask and get answers back.