bot Lx
bot Lx
CDCloudflare Developers
Created by bot Lx on 9/23/2023 in #workers-help
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'
[[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" }
]
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
env.Bucket1
(this is undefined) or
env.r2_buckets[0]
env.r2_buckets[0]
(this is just an Object not a bucket and has no .get(), ...) What am I doing wrong?
13 replies