# 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 %}
