Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accessing binding variable name in wrangler.toml inside functions #93

Open
rohanbam opened this issue Aug 18, 2022 · 0 comments
Open

Accessing binding variable name in wrangler.toml inside functions #93

rohanbam opened this issue Aug 18, 2022 · 0 comments

Comments

@rohanbam
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant