# FilemanagerFiles

## Introduction

`FileManagerFiles` represent a [File](/api-reference/files.md) on the filesystem. `FileManagerFiles` will always attach an `url` to a [File](/api-reference/files.md).

There is no direct relation to a [FilemanagerDirectory](/api-reference/filemanager/filemanager-directories.md). The resolution of files and directories is done by their `path` property.

A file can be saved on any path. If there are no [FilemanagerDirectories](/api-reference/filemanager/filemanager-directories.md) added which represent the sections of the path, the according [FilemanagerDirectories](/api-reference/filemanager/filemanager-directories.md) will be created.

## Model Definition

**Alias**

`filemanagerFile`

**Relations**

| Relation                        | Key    | Type       | Relation Field(s) |
| ------------------------------- | ------ | ---------- | ----------------- |
| [User](/api-reference/users.md) | `user` | Belongs to | `user_id`         |

**Computed Properties**

* `hash` - The hashed `id` of the `FilemanagerFile`
* `name` - The basename of the `FilemanagerFile`
* `url` - Encoded URL to the underlying file

**Traits**

* `SoftDeletes`

## List

Get a list of all `FilemanagerFiles` the current authenticated [User](/api-reference/users.md) is allowed to view.

{% hint style="warning" %}
You can use the filters `matches_path` and `matches_path_recursive` on routes of this module. However, the response time of the list action can be considerably high because of recursive permission handling. You might want to use the [list by path action](#list-by-path) for tasks regarding a specific path.
{% endhint %}

**Definition**

<mark style="color:green;">`GET`</mark> `/api/filemanager/files`

**Example Request**

{% tabs %}
{% tab title="PHP" %}

```php
$client = new GuzzleHttp\Client(['base_uri' => 'https://{tenant}.intratool.de']);
$response = $client->request('GET', '/api/filemanager/files', [
    'headers' => ['Authorization' => "Bearer {accessToken}"]
]);
```

{% endtab %}
{% endtabs %}

**Example Response**

```json
[
  {
    "id": 1,
    "user_id": 3,
    "path": "/Lorem ipsum/Lorem Ipsum.pdf",
    "extension": "pdf",
    "mime_type": "application/pdf",
    "size": 87236,
    "created_at": "2018-12-20 13:58:15",
    "updated_at": "2018-12-21 15:55:10",
    "deleted_at": null,
    "hash": "zn7m24owk63qolxryge8pj05",
    "name": "Lorem Ipsum.pdf",
    "url": "/files/jjee2zq97k8ztpzy67xpreeysxzx00onx940bn884yqqdeow/Lorem Ipsum.pdf"
  },
  {
    "id": 2,
    "user_id": 3,
    "path": "/Lorem ipsum/Dolor sit amet.jpg",
    "extension": "jpg",
    "mime_type": "image/jpeg",
    "size": 187607,
    "created_at": "2018-12-20 13:58:19",
    "updated_at": "2018-12-21 15:55:18",
    "deleted_at": null,
    "hash": "6o8m0kz5yw10x1pr9e4vxj27",
    "name": "Dolor sit amet.jpg",
    "url": "/files/jjee2zq97k8ztpzy67xpreeysxzx00onx940bn884yqqdeow/Dolor sit amet.jpg"
  }
]
```

## List by path

Get a list of all `FilemanagerFiles` by given `{path}` the current authenticated [User](/api-reference/users.md) is allowed to view.

If you don't pass a value for `{path}` a call to the root folder will be assumed.

**Definition**

<mark style="color:green;">`GET`</mark> `/api/filemanager/files/path/{path}`

**Example Request**

{% tabs %}
{% tab title="PHP" %}

```php
$client = new GuzzleHttp\Client(['base_uri' => 'https://{tenant}.intratool.de']);
$response = $client->request('GET', '/api/filemanager/files/path/Lorem%20ipsum', [
    'headers' => ['Authorization' => "Bearer {accessToken}"]
]);
```

{% endtab %}
{% endtabs %}

**Example Response**

```json
[
  {
    "id": 1,
    "user_id": 3,
    "path": "/Lorem ipsum/Lorem Ipsum.pdf",
    "extension": "pdf",
    "mime_type": "application/pdf",
    "size": 87236,
    "created_at": "2018-12-20 13:58:15",
    "updated_at": "2018-12-21 15:55:10",
    "deleted_at": null,
    "hash": "zn7m24owk63qolxryge8pj05",
    "name": "Lorem Ipsum.pdf",
    "url": "/files/jjee2zq97k8ztpzy67xpreeysxzx00onx940bn884yqqdeow/Lorem Ipsum.pdf"
  },
  {
    "id": 2,
    "user_id": 3,
    "path": "/Lorem ipsum/Dolor sit amet.jpg",
    "extension": "jpg",
    "mime_type": "image/jpeg",
    "size": 187607,
    "created_at": "2018-12-20 13:58:19",
    "updated_at": "2018-12-21 15:55:18",
    "deleted_at": null,
    "hash": "6o8m0kz5yw10x1pr9e4vxj27",
    "name": "Dolor sit amet.jpg",
    "url": "/files/jjee2zq97k8ztpzy67xpreeysxzx00onx940bn884yqqdeow/Dolor sit amet.jpg"
  }
]
```

## Count

Get the count of all `FilemanagerFiles` the current authenticated [User](/api-reference/users.md) is allowed to view.

**Definition**

<mark style="color:green;">`GET`</mark> `/api/filemanager/files/count`

**Example Request**

{% tabs %}
{% tab title="PHP" %}

```php
$client = new GuzzleHttp\Client(['base_uri' => 'https://{tenant}.intratool.de']);
$response = $client->request('GET', '/api/filemanager/files/count', [
    'headers' => ['Authorization' => "Bearer {accessToken}"]
]);

```

{% endtab %}
{% endtabs %}

**Example Response**

```json
5
```

## Show

Show a single `FilemanagerFile` by `id`.

**Definition**

<mark style="color:green;">`GET`</mark> `/api/filemanager/files/{id}`

**Example Request**

{% tabs %}
{% tab title="PHP" %}

```php
$client = new GuzzleHttp\Client(['base_uri' => 'https://{tenant}.intratool.de']);
$response = $client->request('GET', '/api/filemanager/files/1', [
    'headers' => ['Authorization' => "Bearer {accessToken}"]
]);
```

{% endtab %}
{% endtabs %}

**Example Response**

```json
{
  "id": 1,
  "user_id": 3,
  "path": "/Lorem ipsum/Lorem Ipsum.pdf",
  "extension": "pdf",
  "mime_type": "application/pdf",
  "size": 87236,
  "created_at": "2018-12-20 13:58:15",
  "updated_at": "2018-12-21 15:55:10",
  "deleted_at": null,
  "hash": "zn7m24owk63qolxryge8pj05",
  "name": "Lorem Ipsum.pdf",
  "url": "/files/jjee2zq97k8ztpzy67xpreeysxzx00onx940bn884yqqdeow/Lorem Ipsum.pdf"
}
```

## Create

Create a new `FilemanagerFile`.

**Definition**

<mark style="color:yellow;">`POST`</mark> `/api/filemanager/files`

**Request Keys**

| Key       |  Type  | Default | Description                                                                |
| --------- | :----: | :-----: | -------------------------------------------------------------------------- |
| `file` \* |  file  |    -    | The File to be uploaded                                                    |
| `path` \* | string |    -    | Relative path to the `FilemanagerFile` (normalized to include leading `/`) |

Keys with `*` are required.

**Example Request**

{% tabs %}
{% tab title="PHP" %}

```php
$client = new GuzzleHttp\Client(['base_uri' => 'https://{tenant}.intratool.de']);
$response = $client->request('POST', '/api/filemanager/files', [
    'headers' => ['Authorization' => "Bearer {$accessToken}"],
    'multipart' => [
        [
            'name' => 'file',
            'contents' => fopen('/path/to/file/Lorem ipsum.pdf', 'r')
        ],
        [
            'name' => 'path',
            'contents' => 'Lorem ipsum.pdf'
        ]
    ]
]);
```

{% endtab %}
{% endtabs %}

**Example Response**

```json
{
  "status": "success",
  "data": {
    "id": 3,
    "user_id": 3,
    "path": "/Lorem ipsum.pdf",
    "extension": "pdf",
    "mime_type": "application/pdf",
    "size": 13997,
    "created_at": "2020-02-12 10:58:12",
    "updated_at": "2020-02-12 10:58:12",
    "hash": "zn7m24owk63qolxryge8pj05",
    "name": "Lorem ipsum.pdf",
    "url": "/api/files/4geewv9rjq6vt8ovz6r8jppv/Lorem ipsum.pdf"
  }
}
```

## Update

Update an existing `FilemanagerFile` by `id`.

**Definition**

<mark style="color:blue;">`PUT`</mark> `/api/filemanager/files/{id}`

**Request Keys**

| Key    |  Type  | Description                                                                |
| ------ | :----: | -------------------------------------------------------------------------- |
| `file` |  file  | The File to be uploaded                                                    |
| `path` | string | Relative path to the `FilemanagerFile` (normalized to include leading `/`) |

**Example Request**

{% tabs %}
{% tab title="PHP" %}

```php
$client = new GuzzleHttp\Client(['base_uri' => 'https://{tenant}.intratool.de']);
$response = $client->request('PUT', '/api/filemanager/files/3', [
    'headers' => ['Authorization' => "Bearer {accessToken}"],
    'json' => [
        'path' => 'Dolor sit amet/Lorem ipsum.pdf'
    ]
]);
```

{% endtab %}
{% endtabs %}

**Example Response**

```json
{
  "status": "success",
  "data": {
    "id": 3,
    "user_id": 3,
    "path": "/Dolor sit amet/Lorem ipsum.pdf",
    "extension": "pdf",
    "mime_type": "application/pdf",
    "size": 13997,
    "created_at": "2020-02-12 10:58:12",
    "updated_at": "2020-02-12 11:10:17",
    "hash": "zn7m24owk63qolxryge8pj05",
    "name": "Lorem ipsum.pdf",
    "url": "/api/files/2yqqxnoe82dnivng6jevz44gcj8j8ry8kkv4i57yrxeonrjjt0dve4g/Lorem ipsum.pdf"
  }
}
```

## Delete

Delete an existing `FilemanagerFile` by `id`.

**Definition**

<mark style="color:red;">`DELETE`</mark> `/api/filemanager/files/{id}`

**Example Request**

{% tabs %}
{% tab title="PHP" %}

```php
$client = new GuzzleHttp\Client(['base_uri' => 'https://{tenant}.intratool.de']);
$response = $client->request('DELETE', '/api/filemanager/files/3', [
    'headers' => ['Authorization' => "Bearer {accessToken}"]
]);
```

{% endtab %}
{% endtabs %}

**Example Response**

```json
{
  "status": "success",
  "data": null
}
```


---

# 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.api.intratool.de/api-reference/filemanager/filemanager-files.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.
