# SiFileUploaderComponent documentation

**Kind:** component

**Selector:** `si-file-uploader`

```
import { SiFileUploaderComponent } from '@siemens/element-ng/file-uploader';
```

```
component SiFileUploaderComponent
```

#### Input Properties

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| [accept](<https://github.com/siemens/element/blob/main/projects/element-ng/file-uploader/si-file-uploader.component.ts#L261-L261>) | `string \| undefined` |  | Define which file types are suggested in file browser.<br><br>See: [https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file\#attr-accept](<https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#attr-accept>) |
| [acceptText](<https://github.com/siemens/element/blob/main/projects/element-ng/file-uploader/si-file-uploader.component.ts#L138-L140>) | `TranslatableString` | `` $localize`:@@SI_FILE_UPLOADER.ACCEPTED_FILE_TYPES:Accepted file types: {{accept}}.` `` | Text for the accepted file types. |
| [autoUpload](<https://github.com/siemens/element/blob/main/projects/element-ng/file-uploader/si-file-uploader.component.ts#L293-L293>) | `boolean` | `false` | Auto-upload mode - automatically start upload once files are added. |
| [cancelButtonText](<https://github.com/siemens/element/blob/main/projects/element-ng/file-uploader/si-file-uploader.component.ts#L185-L185>) | `TranslatableString` | `` $localize`:@@SI_FILE_UPLOADER.CANCEL:Cancel` `` | Text of cancel button. Shown during upload. Required for a11y. |
| [clearButtonText](<https://github.com/siemens/element/blob/main/projects/element-ng/file-uploader/si-file-uploader.component.ts#L158-L158>) | `TranslatableString` | `` $localize`:@@SI_FILE_UPLOADER.CLEAR:Clear` `` | Text used inside the clear button. |
| [directoryUpload](<https://github.com/siemens/element/blob/main/projects/element-ng/file-uploader/si-file-uploader.component.ts#L311-L311>) | `boolean` | `false` | Enable directory upload mode. When enabled, the file input will accept directories and upload all files within as a flat list. The hierarchy of the directory will not be preserved. The `maxFiles` property will have no effect when `directoryUpload` is enabled.<br><br>**Note:** This feature is not yet available for safari (iOS) |
| [disableUpload](<https://github.com/siemens/element/blob/main/projects/element-ng/file-uploader/si-file-uploader.component.ts#L299-L299>) | `boolean` | `false` | Disable the upload button. |
| [errorTextFileMaxSize](<https://github.com/siemens/element/blob/main/projects/element-ng/file-uploader/si-file-uploader.component.ts#L233-L235>) | `TranslatableString` | `` $localize`:@@SI_FILE_UPLOADER.ERROR_FILE_SIZE_EXCEEDED:Max. {{maxFileSize}}` `` | Message or translation key if file exceeds the maximum file size limit. |
| [errorTextFileType](<https://github.com/siemens/element/blob/main/projects/element-ng/file-uploader/si-file-uploader.component.ts#L222-L224>) | `TranslatableString` | `` $localize`:@@SI_FILE_UPLOADER.ERROR_FILE_TYPE:Invalid file type` `` | Text shown to indicate that an incorrect file type was added to file list. |
| [errorUploadFailed](<https://github.com/siemens/element/blob/main/projects/element-ng/file-uploader/si-file-uploader.component.ts#L205-L207>) | `TranslatableString` | `` $localize`:@@SI_FILE_UPLOADER.UPLOAD_FAILED:Upload failed` `` | Text shown if the upload failed. |
| [maxConcurrentUploads](<https://github.com/siemens/element/blob/main/projects/element-ng/file-uploader/si-file-uploader.component.ts#L281-L281>) | `number` | `3` | Maximum number of concurrent uploads. |
| [maxFiles](<https://github.com/siemens/element/blob/main/projects/element-ng/file-uploader/si-file-uploader.component.ts#L275-L275>) | `number` | `10` | Define maximal allowed number of files. When [directoryUpload](<index.html#SiFileUploaderComponent.directoryUpload>) is enabled, this will have no effect. |
| [maxFileSize](<https://github.com/siemens/element/blob/main/projects/element-ng/file-uploader/si-file-uploader.component.ts#L267-L269>) | `number` | `undefined` | Define maximal allowed file size in bytes. |
| [maxFileSizeText](<https://github.com/siemens/element/blob/main/projects/element-ng/file-uploader/si-file-uploader.component.ts#L116-L118>) | `TranslatableString` | `` $localize`:@@SI_FILE_UPLOADER.MAX_SIZE:Upload max. {{maxFileSize}}` `` | Text to describe the maximum file size. |
| [maxFilesReachedText](<https://github.com/siemens/element/blob/main/projects/element-ng/file-uploader/si-file-uploader.component.ts#L127-L129>) | `TranslatableString` | `` $localize`:@@SI_FILE_UPLOADER.MAX_FILE_REACHED:Max. {{maxFiles}} files` `` | Error message shown when the maximum number of files are reached. |
| [removeButtonText](<https://github.com/siemens/element/blob/main/projects/element-ng/file-uploader/si-file-uploader.component.ts#L176-L176>) | `TranslatableString` | `` $localize`:@@SI_FILE_UPLOADER.REMOVE:Remove` `` | Text shown to remove a file from the file list. Required for a11y. |
| [retries](<https://github.com/siemens/element/blob/main/projects/element-ng/file-uploader/si-file-uploader.component.ts#L287-L287>) | `number` | `0` | Numbers of retries for failed uploads. |
| [showHttpError](<https://github.com/siemens/element/blob/main/projects/element-ng/file-uploader/si-file-uploader.component.ts#L213-L213>) | `boolean` | `false` | On failed upload, show the error received from the server. |
| [successTextTitle](<https://github.com/siemens/element/blob/main/projects/element-ng/file-uploader/si-file-uploader.component.ts#L194-L196>) | `TranslatableString` | `` $localize`:@@SI_FILE_UPLOADER.UPLOAD_COMPLETED:Upload completed` `` | Text shown if the upload was successful. |
| [uploadButtonText](<https://github.com/siemens/element/blob/main/projects/element-ng/file-uploader/si-file-uploader.component.ts#L149-L149>) | `TranslatableString` | `` $localize`:@@SI_FILE_UPLOADER.UPLOAD:Upload` `` | Text used inside the upload button. |
| [uploadConfig](<https://github.com/siemens/element/blob/main/projects/element-ng/file-uploader/si-file-uploader.component.ts#L250-L256>) | `FileUploadConfig` | `{     headers: new HttpHeaders({ 'Accept': 'application/json' }),     method: 'POST',     url: '',     fieldName: 'upload_file',     responseType: 'json'   }` | Config for HTTP request to upload file. |
| [uploadDropText](<https://github.com/siemens/element/blob/main/projects/element-ng/file-uploader/si-file-uploader.component.ts#L105-L107>) | `TranslatableString` | `` $localize`:@@SI_FILE_UPLOADER.DROP:Drop files here or click to upload` `` | Text instructing a user to drop the files inside the dropzone. |
| [uploadingText](<https://github.com/siemens/element/blob/main/projects/element-ng/file-uploader/si-file-uploader.component.ts#L167-L167>) | `TranslatableString` | `` $localize`:@@SI_FILE_UPLOADER.UPLOADING:Uploading` `` | Text shown during the file upload. |

#### Output Properties

| Name | Type | Description |
| --- | --- | --- |
| [filesChanges](<https://github.com/siemens/element/blob/main/projects/element-ng/file-uploader/si-file-uploader.component.ts#L327-L327>) | `UploadFile[]` | Output which fires whenever new files are added to or removed from the uploader. |
| [uploadCanceled](<https://github.com/siemens/element/blob/main/projects/element-ng/file-uploader/si-file-uploader.component.ts#L316-L316>) | `UploadFile` | Emits when a user press cancel during upload. The event provides the file details. |
| [uploadCompleted](<https://github.com/siemens/element/blob/main/projects/element-ng/file-uploader/si-file-uploader.component.ts#L322-L322>) | `FileUploadResult` | Output callback event will provide you if upload is finished. If an error occurred it will be emitted. |

#### Attributes and Methods

##### fileUpload

[Source for fileUpload](<https://github.com/siemens/element/blob/main/projects/element-ng/file-uploader/si-file-uploader.component.ts#L452-L458>)

Uploads the file

```
fileUpload(doRetry?: boolean = true): void
```

#### Parameters

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| [doRetry](<https://github.com/siemens/element/blob/main/projects/element-ng/file-uploader/si-file-uploader.component.ts#L452-L452>) (optional) | `boolean` | `true` |  |

**Returns:** [void](<https://www.typescriptlang.org/docs/handbook/2/functions.html#void>)

##### reset

[Source for reset](<https://github.com/siemens/element/blob/main/projects/element-ng/file-uploader/si-file-uploader.component.ts#L439-L447>)

Reset the state.

```
reset(emit?: boolean = true): void
```

#### Parameters

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| [emit](<https://github.com/siemens/element/blob/main/projects/element-ng/file-uploader/si-file-uploader.component.ts#L439-L439>) (optional) | `boolean` | `true` |  |

**Returns:** [void](<https://www.typescriptlang.org/docs/handbook/2/functions.html#void>)

### Types Documentation

### [FileUploadConfig](<https://github.com/siemens/element/blob/main/projects/element-ng/file-uploader/si-file-uploader.component.ts#L49-L73>)

**Kind:** interface

```
import type { FileUploadConfig } from '@siemens/element-ng/file-uploader';
```

```
interface FileUploadConfig
```

#### Properties

<table><thead><tr><th>Name</th><th>Type</th><th>Description</th></tr></thead> <tbody><tr id="t:FileUploadConfig.additionalFields"> <td class="api-column-name"><a href="https://github.com/siemens/element/blob/main/projects/element-ng/file-uploader/si-file-uploader.component.ts#L63-L63">additionalFields</a> (optional)</td> <td class="api-column-type"><code>Record&lt;<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>, <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>&gt;</code></td> <td class="api-column-description"><p>Additional form fields added in the HTTP request.</p><p>Example:</p><pre><code class="language-json">{ upload_user: 'Reiner Zufall', expiry_date: ' 21.12.2012' }</code></pre></td></tr><tr id="t:FileUploadConfig.fieldName"> <td class="api-column-name"><a href="https://github.com/siemens/element/blob/main/projects/element-ng/file-uploader/si-file-uploader.component.ts#L54-L54">fieldName</a></td> <td class="api-column-type"><code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code></td> <td class="api-column-description"><p>Form field name for the uploaded file.</p></td></tr><tr id="t:FileUploadConfig.handler"> <td class="api-column-name"><a href="https://github.com/siemens/element/blob/main/projects/element-ng/file-uploader/si-file-uploader.component.ts#L67-L67">handler</a> (optional)</td> <td class="api-column-type"><code>((req: <a href="https://angular.dev/api/common/http/HttpRequest">HttpRequest</a>&lt;<a href="https://www.typescriptlang.org/docs/handbook/2/functions.html#unknown">unknown</a>&gt;) =&gt; <a href="https://rxjs.dev/api/index/class/Observable">Observable</a>&lt;<a href="https://angular.dev/api/common/http/HttpEvent">HttpEvent</a>&lt;<a href="https://www.typescriptlang.org/docs/handbook/2/functions.html#unknown">unknown</a>&gt;&gt;)</code></td> <td class="api-column-description"><p>A function to modify the HTTP request sent on the consumer side.</p></td></tr><tr id="t:FileUploadConfig.headers"> <td class="api-column-name"><a href="https://github.com/siemens/element/blob/main/projects/element-ng/file-uploader/si-file-uploader.component.ts#L50-L50">headers</a></td> <td class="api-column-type"><code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a> | <a href="https://angular.dev/api/common/http/HttpHeaders">HttpHeaders</a> | Record&lt;<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>, <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a> | <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a> | (<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a> | <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>)[]&gt; | <a href="https://developer.mozilla.org/docs/Web/API/Headers">Headers</a></code></td> <td class="api-column-description"></td></tr><tr id="t:FileUploadConfig.method"> <td class="api-column-name"><a href="https://github.com/siemens/element/blob/main/projects/element-ng/file-uploader/si-file-uploader.component.ts#L51-L51">method</a></td> <td class="api-column-type"><code>&quot;POST&quot; | &quot;PUT&quot; | &quot;PATCH&quot;</code></td> <td class="api-column-description"></td></tr><tr id="t:FileUploadConfig.responseType"> <td class="api-column-name"><a href="https://github.com/siemens/element/blob/main/projects/element-ng/file-uploader/si-file-uploader.component.ts#L65-L65">responseType</a> (optional)</td> <td class="api-column-type"><code>&quot;arraybuffer&quot; | &quot;blob&quot; | &quot;json&quot; | &quot;text&quot;</code></td> <td class="api-column-description"><p>Specify the server response type</p></td></tr><tr id="t:FileUploadConfig.sendBinary"> <td class="api-column-name"><a href="https://github.com/siemens/element/blob/main/projects/element-ng/file-uploader/si-file-uploader.component.ts#L72-L72">sendBinary</a> (optional)</td> <td class="api-column-type"><code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></code></td> <td class="api-column-description"><p>When <code>true</code>, the file will be sent directly w/o the use of <code>FormData</code>. You will also need to set the <code>Content-Type</code> header when sending binary. See: <a href="index.html#t:FileUploadConfig.headers">headers</a></p></td></tr><tr id="t:FileUploadConfig.url"> <td class="api-column-name"><a href="https://github.com/siemens/element/blob/main/projects/element-ng/file-uploader/si-file-uploader.component.ts#L52-L52">url</a></td> <td class="api-column-type"><code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code></td> <td class="api-column-description"></td></tr></tbody></table>

### [TranslatableString](<https://github.com/siemens/element/blob/main/projects/element-translate-ng/translate-types/global.types.ts#L18-L18>)

**Kind:** type alias

```
import type { TranslatableString } from '@siemens/element-translate-ng/translate-types';
```

Represents a translatable string. This can either be a translation key, e.g. `ACTIONS.EDIT` that will be automatically translated when displayed on the UI or a pre-translated string, e.g. `Edit`. Equivalent to a normal string in usage and functionality.

```
type TranslatableString = string & Translatable
```

### [FileUploadResult](<https://github.com/siemens/element/blob/main/projects/element-ng/file-uploader/si-file-uploader.component.ts#L43-L47>)

**Kind:** interface

```
import type { FileUploadResult } from '@siemens/element-ng/file-uploader';
```

The FileUploadResult is emitted at completion of the file uploading via the `uploadCompleted` emitter. On success the Http `response` from the backend is provided and on failure, the `error` object is available.

```
interface FileUploadResult
```

#### Properties

| Name | Type | Description |
| --- | --- | --- |
| [error](<https://github.com/siemens/element/blob/main/projects/element-ng/file-uploader/si-file-uploader.component.ts#L46-L46>) (optional) | `Error` |  |
| [file](<https://github.com/siemens/element/blob/main/projects/element-ng/file-uploader/si-file-uploader.component.ts#L44-L44>) | `string` |  |
| [response](<https://github.com/siemens/element/blob/main/projects/element-ng/file-uploader/si-file-uploader.component.ts#L45-L45>) (optional) | `HttpResponse<unknown>` |  |

### [UploadFile](<https://github.com/siemens/element/blob/main/projects/element-ng/file-uploader/si-file-uploader.model.ts#L9-L17>)

**Kind:** interface

```
import type { UploadFile } from '@siemens/element-ng/file-uploader';
```

```
interface UploadFile
```

#### Properties

| Name | Type | Description |
| --- | --- | --- |
| [errorParams](<https://github.com/siemens/element/blob/main/projects/element-ng/file-uploader/si-file-uploader.model.ts#L15-L15>) (optional) | `Record<string, unknown>` |  |
| [errorText](<https://github.com/siemens/element/blob/main/projects/element-ng/file-uploader/si-file-uploader.model.ts#L14-L14>) (optional) | `TranslatableString` |  |
| [file](<https://github.com/siemens/element/blob/main/projects/element-ng/file-uploader/si-file-uploader.model.ts#L11-L11>) | `File` |  |
| [fileName](<https://github.com/siemens/element/blob/main/projects/element-ng/file-uploader/si-file-uploader.model.ts#L12-L12>) | `string` |  |
| [progress](<https://github.com/siemens/element/blob/main/projects/element-ng/file-uploader/si-file-uploader.model.ts#L16-L16>) | `number` |  |
| [size](<https://github.com/siemens/element/blob/main/projects/element-ng/file-uploader/si-file-uploader.model.ts#L13-L13>) | `string` |  |
| [status](<https://github.com/siemens/element/blob/main/projects/element-ng/file-uploader/si-file-uploader.model.ts#L10-L10>) | `"error" \| "success" \| "added" \| "invalid" \| "queued" \| "uploading"` |  |
