# Cybus::File

The **Cybus::File** resource allows you to define and provision files directly into a specified [volume](#volume). The file content is provided in the service commissioning file and written into the target volume at the defined path.

This is useful for adding configuration files, static assets, or other resources required by a container.

{% hint style="warning" %}
This resource is supported only in Docker Compose deployments. It is not available in Kubernetes deployments of Connectware. Attempting to use it in Kubernetes will result in an error.
{% endhint %}

## Lifecycle Behavior

* **Creation**: When the service is enabled, the file is created inside the referenced volume with the specified content. If the file already exists, its contents may be overwritten depending on the selected `writeMode`.
* **Persistence**: Connectware does not delete or truncate files after creation.
* **Deletion**: The file is removed only if its parent volume is manually deleted.

## File Properties

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

### volume

The reference to the Docker volume to which this file should be written.

* Type: `string`

### filepath

The absolute path and filename of the file to be written inside the volume.

* Type: `string`

### content

The content of the file as a base64 encoded string.

* Type: `string`

### writeMode

Specifies the writing mode when writing the file.

* `create`: Create the file with the given content if it does not exist. If it exists, check whether it has the given content, and if it has different content, throw an error (i.e., don’t overwrite any different content).
* `overwrite`: Create the file with the given content, either creating it newly or overwriting a previously existing file.
* `append`: Append the given content to the file. If it already exists, the given content is appended. If it does not exist, the file is newly created with the given content.
* Type: `enum` which must be one of these values: `create`, `overwrite`, `append`.
* Default: `create`

## Example

{% code lineNumbers="true" %}

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

myFile:
  type: Cybus::File
  properties:
    volume: !ref myVolume
    filepath: '/data/myFile.txt'
    content: 'Zm9vYmFyCg=='
    writeMode: create
```

{% endcode %}


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.cybus.io/2-1-2/documentation/services/service-commissioning-files/resources/cybus-file.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
