Open rohanbam opened 2 years ago
I want to access an r2 bucket from a vitedge function. Cloudflare docs state that in order to access r2 bucket from a worker, it is necessary to bind worker to r2 bucket using the following syntax inside wrangler.toml
r2_buckets = [ { binding = "BUCKET-1", bucket_name = "bucket-1", preview_bucket_name = "bucket-1" }, { binding = "BUCKET-2", bucket_name = "bucket-2", preview_bucket_name = "bucket-2" } ]
and then, use that binding inside the worker as follows const object = await env.Bucket1.get(objectName, ...)
however, in the above line env is undefined inside vitedge functions.
can you provide an example of how this binding variable can be accessed?
I want to access an r2 bucket from a vitedge function. Cloudflare docs state that in order to access r2 bucket from a worker, it is necessary to bind worker to r2 bucket using the following syntax inside wrangler.toml
r2_buckets = [ { binding = "BUCKET-1", bucket_name = "bucket-1", preview_bucket_name = "bucket-1" }, { binding = "BUCKET-2", bucket_name = "bucket-2", preview_bucket_name = "bucket-2" } ]
and then, use that binding inside the worker as follows const object = await env.Bucket1.get(objectName, ...)
however, in the above line env is undefined inside vitedge functions.
can you provide an example of how this binding variable can be accessed?