> For the complete documentation index, see [llms.txt](https://docs.cybus.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.cybus.io/data-flows/service-commissioning-files/resources/cybus-file.md).

# Cybus::File

Write configuration files or other content into a volume when you enable a service, so that containers find it at a fixed path.

The **Cybus::File** resource writes a file into a [Cybus::Volume](https://docs.cybus.io/data-flows/service-commissioning-files/resources/cybus-volume.md). You give the content in the service commissioning file, and Connectware writes it to the path that you set. Use it for configuration files, static assets, or other files that a container needs.

{% hint style="warning" %}
This resource works only in Docker Compose deployments of Connectware. In a Kubernetes deployment, it results in an error.
{% endhint %}

## File Properties

| Property                | Type     | Required     | Default  |
| ----------------------- | -------- | ------------ | -------- |
| [volume](#volume)       | `string` | **Required** |          |
| [filepath](#filepath)   | `string` | **Required** |          |
| [content](#content)     | `string` | **Required** |          |
| [writeMode](#writemode) | `enum`   | Optional     | `create` |

### volume

A reference to the Docker volume that Connectware writes the file to, usually a [Cybus::Volume](https://docs.cybus.io/data-flows/service-commissioning-files/resources/cybus-volume.md) resource of the service, for example `!ref myVolume`.

* **Required**
* Type: `string`

### filepath

The absolute path and file name of the file inside the volume, for example `/data/myFile.txt`. A container that mounts the volume at `/mnt` finds this file at `/mnt/data/myFile.txt`.

* **Required**
* Type: `string`

### content

The content of the file, as a base64-encoded string.

* **Required**
* Type: `string`

### writeMode

The write mode, which decides how Connectware handles a file that already exists.

* **Optional**
* Type: `enum`
  * Allowed values: `create`, `overwrite`, `append`
* Default: `create`

The write modes work as follows:

* `create`: Creates the file with the given content if it does not exist. If the file exists with different content, Connectware returns an error and leaves the file unchanged.
* `overwrite`: Creates the file with the given content, or replaces an existing file.
* `append`: Appends the given content to an existing file, or creates the file with the given content if it does not exist.

## Lifecycle Behavior

* **Creation**: When you enable the service, Connectware writes the file into the volume. If the file already exists, the [writeMode](#writemode) decides whether Connectware overwrites it.
* **Persistence**: Connectware never deletes or truncates the file, not even when you disable or uninstall the service.
* **Deletion**: The file is removed only when you delete its volume manually.

## Example

{% code lineNumbers="true" %}

```yaml
myVolume:
  type: Cybus::Volume

myFile:
  type: Cybus::File
  properties:
    volume: !ref myVolume
    filepath: '/data/myFile.txt'
    content: 'Zm9vYmFyCg==' # "foobar" and a line break, base64-encoded
    writeMode: create
```

{% endcode %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.cybus.io/data-flows/service-commissioning-files/resources/cybus-file.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
