Creates the bucket if it does not exist yet. Buckets are private by default, public read access gets
granted by connecting a custom domain or by enabling the r2.dev public development URL of the bucket.
Public access can also be enabled on existing buckets, but this function never turns it off.
Arguments
- r2_bucket
bucket name, or the bucket as
r2://bucketlike the other functions address it.- public
FALSE(default) orTRUE: enable public read access via ther2.devURL. Ignored ifcustom_domainis set.- custom_domain
domain to connect to the bucket for public read access, like
data.example.com, optional. Ther2.devURL does not get enabled then.
Details
Cloudflare rate limits access via r2.dev, for heavier use connect a custom domain. Each custom domain can
only serve one bucket, use subdomains like data.example.com to serve several buckets from one zone.
Credentials
The R2 account id and the value of an R2 API token with admin read and write permissions have to be in the
R2_ACCOUNT_ID and R2_API_TOKEN environment variables. For connecting a custom domain the token also
needs Zone Read permission for the domain's zone, which has to be an active zone in the same Cloudflare
account. With Zone Cache Purge permission as well, upload_parquet() and remove_parquet() purge changed files
from the cache.
