How can I access R2 buckets binding when binding multiple buckets

Hi I am currently trying to bind 2 R2 buckets to my worker.

When I do it like this it works for one bucket:
[[r2_buckets]]
binding = 'Bucket1'
bucket_name = 'bucket1'


However when binding like this I cant access the bindings in the worker:
r2_buckets = [
    { binding = "Bucket1", bucket_name = "bucket1", preview_bucket_name = "bucket1" },
    { binding = "Bucket2", bucket_name = "bucket2", preview_bucket_name = "bucket2" }
]


I have tried accessing the bucket via
env.Bucket1
(this is undefined) or
env.r2_buckets[0]
(this is just an Object not a bucket and has no .get(), ...)

What am I doing wrong?
Was this page helpful?