rebase.Bucket
Object storage addressed by key, backed one-to-one by a real cloud bucket.
Signature
class rebase.Bucket(
name: str,
*,
create_if_missing: bool = False,
client: rebase.Client | None = None,
environment_name: str | None = None,
)A named object store: keys and objects, not files and directories. Unlike
rebase.Volume it is never mounted, so nothing pretends
an object store is a filesystem — a write costs one request rather than a
read-modify-write of the whole object. See Buckets for
the full guide.
import rebase as rb
b = rb.Bucket.from_name("forecasts", create_if_missing=True)
b.put("2026/08/10.parquet", data)
@rb.function(buckets=["forecasts"])
def train():
import pandas as pd
return pd.read_parquet(rb.Bucket.from_name("forecasts").uri + "/2026/08/10.parquet")Parameters
| Parameter | Type | Description |
|---|---|---|
name | str | Bucket name: lowercase letters, digits, ., _, -; must start and end alphanumeric. |
create_if_missing | bool | Create the bucket lazily on first use (or at deploy time when the handle is passed to buckets=). |
client | `rebase.Client | None` |
environment_name | `str | None` |
Constructors
rebase.Bucket.from_name(name: str, *, create_if_missing: bool = False,
environment_name: str | None = None) -> rebase.BucketAttributes
| Attribute | Type | Description |
|---|---|---|
uri | str | The bucket's gs:// URI, for handing to pandas, polars, duckdb, or fsspec. Inside a deployed run this is read from the injected REBASE_BUCKET_<NAME> environment variable, so it costs nothing; elsewhere it is fetched once and cached. |
Methods
b.ensure(client: rebase.Client | None = None) -> dict[str, Any]
b.put(key: str, data: bytes | str | Path, *, content_type: str | None = None) -> str
b.put_file(local_path: str | Path, key: str | None = None, *,
content_type: str | None = None) -> str
b.put_directory(local_dir: str | Path, prefix: str = "") -> Sequence[str]
b.get(key: str) -> bytes
b.download(key: str, local_path: str | Path) -> Path
b.list(prefix: str = "", *, delimiter: str | None = None,
limit: int = 1000, page_token: str | None = None) -> dict[str, Any]
b.iter_all(prefix: str = "") -> Iterator[rebase.client.BucketObject]
b.stat(key: str) -> dict[str, Any]
b.exists(key: str) -> bool
b.delete(key: str) -> None
b.delete_prefix(prefix: str = "") -> int
b.signed_url(key: str, *, method: str = "GET", content_type: str | None = None) -> str
b.signed_urls(keys: Sequence[str], *, method: str = "GET") -> dict[str, str]| Method | Description |
|---|---|
ensure() | Make sure the bucket exists (creates it when create_if_missing); returns the bucket record. |
put(key, data) | Write one object. Accepts bytes, text, or a Path to upload. |
put_file(local_path, key=None) | Upload one local file, streaming. Defaults to the file's basename as key. |
put_directory(local_dir, prefix="") | Recursively upload a directory; signs URLs in batches of 100 rather than one per file. Returns the keys written. |
get(key) | Read one object into memory. |
download(key, local_path) | Download one object to disk, streaming. |
list(prefix, delimiter=, limit=, page_token=) | One page of objects: {"objects": [...], "prefixes": [...], "next_page_token": ...}. Pass delimiter="/" to browse folder-style. |
iter_all(prefix) | Every object under a prefix, following pagination transparently. |
stat(key) | Metadata for one object, including checksums and generation. |
exists(key) | Whether the object exists. |
delete(key) | Delete one object. Deleting the bucket itself is Client.delete_bucket(name) or rebase bucket delete. |
delete_prefix(prefix) | Delete every object under a prefix, paged from the client side; returns the number deleted. |
signed_url(key, method=, content_type=) | A short-lived presigned URL for one object. |
signed_urls(keys, method=) | Presigned URLs for many objects in batched round trips. Signing non-GET methods requires buckets:write. |
Uploads and downloads (put*, get, download) move bytes over presigned URLs,
directly between you and object storage. Metadata and deletion (stat, exists,
delete) go through the platform API.
BucketObject
list() and iter_all() yield rebase.client.BucketObject items (not exported at the top level):
| Field | Type | Description |
|---|---|---|
key | str | Object key. |
size | int | Size in bytes. |
updated | `str | None` |
content_type | `str | None` |
etag | `str | None` |
version | `str | None` |
digest | `str | None` |
Attaching to Deployed Code
Pass bucket names or handles to buckets= on rebase.function(...),
rebase.workflow(...), or rebase.asgi_app(...). Each attachment injects the bucket's gs:// URI as
REBASE_BUCKET_<NAME> (uppercased, every run of non-alphanumerics becoming one _)
and grants the runtime service account access, so deployed code reads gs:// paths at
full speed without signed URLs.
A handle with create_if_missing=True is created at deploy time. Function bucket
attachments require isolation="dedicated" or mode="job".

