# Bucket

> For AI agents: the complete documentation index is at https://buddy.works/llms.txt

A Bucket artifact stores any files as versions, each with its own HTTPS address. Upload from the UI, CLI or a pipeline and download with a browser, curl or bdy.

A Bucket artifact stores any files: a website build, binaries, test reports. Each version has its own HTTPS address in the `bucket-2.registry.sh` domain, and you download the files with a browser, `curl`, the `bdy` CLI or an action in a pipeline.

## Creating a Bucket artifact

You can create a Bucket artifact using the UI or CLI.

### Create a Bucket artifact in the UI

In the project sidebar, open **Artifacts**, click **New artifact** and select **Bucket**. The form has the fields **Name**, **Scope**, **Initial version name** (`1.0.0` by default) and **Access control**.

![New Bucket artifact form](https://buddy.works/docs/artifacts/artifacts-new-bucket-form.png)

Upon creation, the artifact contains an initial empty version.

### Create a Bucket from the CLI

```bash
bdy artifact create my-app-build -b -p my-project
```

The `-b` flag sets Buddy Auth. Without `-b` and `-a`, the artifact is public ([Access control](https://buddy.works/docs/artifacts/access-control.md)).

## How do I upload files to a version?

You upload files to a version in the **Browse** tab, from the CLI or with the **Publish Artifact Version** action in a pipeline.

### Upload files in the web interface

Open the **Browse** tab and select a version. An empty version shows the **Empty filesystem** section with a drop zone for files and an **Add file** button.

![Empty Bucket artifact version](https://buddy.works/docs/artifacts/artifacts-bucket-empty-version.png)

To create a new version for the upload, use the **New version** button in the **Versions** tab, described on the [Versions](https://buddy.works/docs/artifacts/versions.md) page.

### Upload files from the CLI

`bdy artifact publish` sends a directory as a new version:

```bash
bdy artifact publish my-app-build:1.2.0 ./dist -p my-project
```

Without a version name, the files go to the `latest` version. If the version already exists, the CLI fails, and the `-f` flag replaces all of its content.

### Upload files in a pipeline

The **Publish Artifact Version** action sends a directory from the pipeline filesystem (`local_path`) to one or more versions. A complete YAML example is in [Quickstart](https://buddy.works/docs/artifacts/quickstart.md), and the action fields are in [Artifacts in pipelines](https://buddy.works/docs/artifacts/pipelines.md). Uploading files through the REST API is described in the [API reference](https://buddy.works/docs/api/artifacts/versions/upload.md).

## What is the address of a version?

Each version has an address in the format `https://<version>-<artifact>-<workspace>.bucket-2.registry.sh`. Dots in the version name turn into hyphens, and the `latest` version has no version prefix.

| Version | Address |
| :--- | :--- |
| `1.2.0` | `https://1-2-0-my-app-build-my-workspace.bucket-2.registry.sh` |
| `build-42` | `https://build-42-my-app-build-my-workspace.bucket-2.registry.sh` |
| `latest` | `https://my-app-build-my-workspace.bucket-2.registry.sh` |

The root address of a version serves the `index.html` file, and the other files are available under their paths, e.g. `/assets/app.js`. A missing file returns 404. This way a version works as a static website, e.g. a build from Next.js, Vue.js or Astro.

## Serve a version under your own domain

You can serve a version under your own domain in the **Routing** module. In the **Add a new route** form, set **Upstream type** to **Artifact** and select the version, e.g. `web-app-build:build-2`.

![Route with an artifact version as the upstream](https://buddy.works/docs/artifacts/artifact-route-add.png)

![Route to an artifact on the Routing list](https://buddy.works/docs/artifacts/artifact-route-list.png)

Routing does not bypass the artifact's access control settings. If Buddy Auth is enabled, unauthenticated requests are redirected to the Buddy login page.

## Artifact version access control

Access to the version address depends on the **Access control** field in the artifact's **Settings** tab:

| Access control | Unauthenticated response | Authentication requirements |
| :--- | :--- | :--- |
| **Buddy Auth** | HTTP `302` redirect to `https://app.buddy.works/artifact/auth` | Authenticate with a Buddy account |
| **HTTP BA** | HTTP `401 Unauthorized` with the `www-authenticate: Basic realm="package"` header | Provide the username and password configured for the artifact |
| **Public** | HTTP `200 OK` | No authentication required |

With HTTP Basic Auth, you download a file with `curl` and the `-u` flag:

```bash
curl -u mike:<password> -O https://1-2-0-my-app-build-my-workspace.bucket-2.registry.sh/report.pdf
```

A wrong password also returns 401. `bdy artifact download` works regardless of Access control, because it authenticates with the CLI token.

## Download files from a Bucket artifact

- **UI** - in the **Browse** tab, the file menu has **Download** and **Raw**. The **⋮** menu next to a version in the **Versions** tab also has **Download** and **Open in browser**.
- **CLI** - `bdy artifact download my-app-build:1.2.0 ./out -p my-project`. Without a version name, the CLI downloads `latest`, and if it does not exist, the most recently created version. A non-empty target directory requires the `-m` flag (keeps local files) or `-r` (clears the directory).
- **Pipeline** - the **Download Artifact Version** action saves the files in the pipeline filesystem. The filesystem persists between runs, so set `overwrite: true` when you download to the same directory again.
- **Run with a version** - a pipeline run with a selected version has its files in the working directory without a Download action. See [Run a pipeline with an artifact version](https://buddy.works/docs/artifacts/run-with-version.md).
- **Sandbox** - you can download a version to a sandbox, as described in [Git and artifacts in Sandboxes](https://buddy.works/docs/sandboxes/git-and-artifacts.md).

![Browse tab with the files of an artifact version](https://buddy.works/docs/artifacts/artifact-browse.png)

See also:

- [Versions](https://buddy.works/docs/artifacts/versions.md) - version names, copying and deleting
- [Access control](https://buddy.works/docs/artifacts/access-control.md) - Buddy Auth, HTTP Basic Auth and public access
- [Artifacts in pipelines](https://buddy.works/docs/artifacts/pipelines.md) - Publish and Download actions and `BUDDY_ARTIFACT_*` variables
- [bdy artifact](https://buddy.works/docs/cli/artifact.md) - `publish`, `download` and `create` flags


---
Original source: https://buddy.works/docs/artifacts/bucket