# Save File

### Overview

The **File Storage Component** allows saving a file to the database with its metadata, including filename, MIME type, and encoding. This component enables efficient file storage and retrieval for various applications.

### Usage

This component is useful when files need to be uploaded and stored securely in a database for further processing or retrieval.

#### Properties

| Property          | Type               | Description                                                   |
| ----------------- | ------------------ | ------------------------------------------------------------- |
| `filename`        | `string`           | The name of the file to be stored.                            |
| `mimetype`        | `string`           | The MIME type of the file.                                    |
| `content`         | `array` / `string` | The content of the file to be saved.                          |
| `contentEncoding` | `string`           | The encoding format of the content (e.g., utf8, base64, hex). |

#### Input Ports

| Port | Description                           |
| ---- | ------------------------------------- |
| `in` | Accepts the file details for storage. |

#### Output Ports

| Port   | Description                                     |
| ------ | ----------------------------------------------- |
| `file` | Emits metadata of the successfully stored file. |

#### Processing Logic

1. **Receives Input Data**:
   * Accepts `filename`, `mimetype`, `content`, and `contentEncoding`.
2. **Saves the File**:
   * Stores the file in the database.
   * Uses the specified encoding format for content.
3. **Confirms Storage**:
   * Emits metadata of the stored file, including its unique `fileId`, `filename`, and `contentType`.
   * If an error occurs (e.g., invalid content), it is logged or raised appropriately.

#### Output Data Schema

| Property      | Type     | Description                        |
| ------------- | -------- | ---------------------------------- |
| `fileId`      | `string` | The identifier of the stored file. |
| `filename`    | `string` | The name of the stored file.       |
| `contentType` | `string` | The MIME type of the stored file.  |

### Notes

* **Supports Various Encoding Formats**: Content encoding options include `utf8`, `base64`, `hex`, and more.
* **Secure and Reliable Storage**: Ensures files are stored securely in the database.
* **Ideal for File Upload and Management Workflows**: Enables seamless file handling for applications requiring document storage and retrieval.


---

# 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.appmixer.com/connector-configuration/utils/files/save-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.
