> For the complete documentation index, see [llms.txt](https://docs.appmixer.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.appmixer.com/connector-configuration/utils/ftp/upload-file.md).

# Upload File

### Overview

The **Upload File Component** enables users to upload files to a remote FTP or SFTP server. It ensures seamless file transfer for automated workflows requiring remote storage management.

### Usage

This component connects to an FTP/SFTP server and uploads a specified file to a given path.

#### Properties

| Property | Type     | Description                                                                                                                          |
| -------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------ |
| `fileId` | `string` | The unique identifier of the file to upload.                                                                                         |
| `path`   | `string` | The full path where the file should be stored, including the filename. If a file already exists at the path, it will be overwritten. |

#### Input Ports

| Port | Description                                     |
| ---- | ----------------------------------------------- |
| `in` | Accepts the file ID and target path for upload. |

#### Output Ports

| Port    | Description                                                                                   |
| ------- | --------------------------------------------------------------------------------------------- |
| `out`   | Emits the uploaded file’s ID upon successful transfer.                                        |
| `error` | Emits an error if the upload fails due to invalid paths, missing files, or permission issues. |

#### Processing Logic

1. **Establishes FTP/SFTP Connection**: Securely connects to the remote server using provided authentication credentials.
2. **Reads the Input File**:
   * Retrieves the file stream from the provided `fileId`.
3. **Uploads the File**:
   * Transfers the file to the specified `path`.
   * If a file with the same name exists, it is overwritten.
4. **Handles Success & Errors**:
   * If successful, sends the uploaded file’s `fileId` to the `out` port.
   * If an error occurs (e.g., path is an existing directory or lacks permissions), emits a descriptive error to the `error` port.
5. **Closes Connection**: Ensures the FTP/SFTP session is properly terminated.

#### Output Data Schema

| Property                  | Type     | Description                                 |
| ------------------------- | -------- | ------------------------------------------- |
| `fileId`                  | `string` | The unique identifier of the uploaded file. |
| `errorCode` (if error)    | `string` | FTP/SFTP error code.                        |
| `errorMessage` (if error) | `string` | Description of the error encountered.       |

### Notes

* **Supports FTP & SFTP**: Works with both FTP and secure FTP (SFTP) connections.
* **Overwrites Existing Files**: If a file exists at the target path, it will be replaced.
* **Error Handling**: Properly manages missing files, invalid paths, and permission-related issues.
* **Efficient File Transfer**: Enables automated file uploads to remote servers.

This component is ideal for workflows that require seamless file transfers to remote FTP/SFTP servers.


---

# 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 dynamically by asking a question.

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

```
GET https://docs.appmixer.com/connector-configuration/utils/ftp/upload-file.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
