> For the complete documentation index, see [llms.txt](https://eohelp.weaver.com.co/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://eohelp.weaver.com.co/open-api/2-attachment.md).

# 2 Attachment

## Get a list of attachments

<mark style="color:green;">`POST`</mark> `api/attachment/list`

#### Request Body

| Name        | Type  | Description              |
| ----------- | ----- | ------------------------ |
| attach\_ids | array | Attachment ID Collection |

{% tabs %}
{% tab title="200: OK " %}
{% tabs %}
{% tab title="Result" %}

{% endtab %}

{% tab title="Example" %}

```json
{
 "status": 1,
 "data": [
[
'id' => 1600, //Primary id
'attachment_id' => '61bb77aa7c4eb8e3bb8b20c0ac72ab1e', //attachmetn id
'attachment_name' => '图20160314105710.png', //Attachment name
'affect_attachment_name' => '9a28e37c0a9bae896ea2fa9bce07fe1c.png', //Attachment system name, avoid user copy from server
'attachment_relative_path' => '2018/05/31/61bb77aa7c4eb8e3bb8b20c0ac72ab1e/', //Attachment path
'attachment_type' => 'png', //Attachment type
'attachment_mark' => 1, //Attachment mark
'category' => 1, //Attachment category
'relation_table' => "document_content", //Related table
'thumb_attachment_name' => "data:image/png;base64,iVBORw0K.....==", //Attachment Thumbnail
'attachment_size' => 2250, //Size
'attachment_time' => "2018-05-31 16:40:30", //Upload time
'attachment_path' => "attachment\index\61bb77aa7c4eb8e3bb8b20c0ac72ab1e", //Download path
],
......
]
}
```

{% endtab %}
{% endtabs %}
{% endtab %}

{% tab title="400: Bad Request " %}
{% tabs %}
{% tab title="Result" %}

{% endtab %}

{% tab title="Example" %}

```json
{
    "status": 0,
    "errors": [
        {
            "code": "0x000003",
            "message": "未知错误"
        }
    ]
}
```

{% endtab %}
{% endtabs %}
{% endtab %}
{% endtabs %}

| Name   | Type    | Description                  |
| ------ | ------- | ---------------------------- |
| status | boolean | (0) Access failed            |
| errors | array   | Access failure error message |

| Field  | Type    | Description              |
| ------ | ------- | ------------------------ |
| status | boolean | (1) Access is successful |
| data   | array   | back to attachment       |

## Attachment Upload

<mark style="color:blue;">`GET`</mark> `api/attachment/upload`

#### Request Body

| Name              | Type   | Description                                                                                                                   |
| ----------------- | ------ | ----------------------------------------------------------------------------------------------------------------------------- |
| name              | string | File name If this value is passed in, use this value as the file name, otherwise generate a name based on the uploaded file   |
| Filedata          | file   | The value of the file upload name is fixed as Filedata, and the uploaded file information is $\_FILES\['Filedata']            |
| attachment\_table | string | Association table name, optional, if this value is passed in, this attachment will be associated with the corresponding table |
| chunks            | int    | The number of all uploaded slices                                                                                             |
| chunk             | int    | The index of the currently uploaded slice, starting from 0                                                                    |

{% tabs %}
{% tab title="200: OK " %}
{% tabs %}
{% tab title="Result" %}

{% endtab %}

{% tab title="Example" %}

```json
{
 "status": 1,
 "data": {
     "attachment_id": "61bb77aa7c4eb8e3bb8b20c0ac72ab1e", //attachment id
     "attachment_name": "图20160314105710.png"  //file name
  }
}
```

{% endtab %}
{% endtabs %}
{% endtab %}

{% tab title="400: Bad Request " %}
{% tabs %}
{% tab title="Result" %}

{% endtab %}

{% tab title="Example" %}

```json
{
    "status": 0,
    "errors": [
        {
            "code": "0x000003",
            "message": "未知错误"
        }
    ]
}
```

{% endtab %}
{% endtabs %}
{% endtab %}
{% endtabs %}

| Name   | Type    | Description                  |
| ------ | ------- | ---------------------------- |
| status | boolean | (0) Access failed            |
| errors | array   | Access failure error message |

| Field  | Type    | Description                        |
| ------ | ------- | ---------------------------------- |
| status | boolean | (1) uploaded successfully          |
| data   | array   | Returns the attachment id and name |

## Get Attachments

<mark style="color:blue;">`GET`</mark> `api/attachment/index/{attachmentId}`

#### Path Parameters

| Name           | Type   | Description                  |
| -------------- | ------ | ---------------------------- |
| encrypt        | string | Fixed value: 0               |
| attachment\_id | string | Attachment ID                |
| operate        | string | The fixed value is: download |

{% tabs %}
{% tab title="200: OK " %}
{% tabs %}
{% tab title="Result" %}

{% endtab %}
{% endtabs %}
{% endtab %}

{% tab title="400: Bad Request " %}
{% tabs %}
{% tab title="Result" %}

{% endtab %}

{% tab title="Example" %}

```json
{
    "status": 0,
    "errors": [
        {
            "code": "0x011017",
            "message": "文件不存在"
        }
    ]
}
```

{% endtab %}
{% endtabs %}
{% endtab %}
{% endtabs %}

| Name   | Type    | Description                  |
| ------ | ------- | ---------------------------- |
| status | boolean | (0) Access failed            |
| errors | array   | Access failure error message |

| Field      | Type     | Description              |
| ---------- | -------- | ------------------------ |
| status     | boolean  | (1) Access is successful |
| attachment | resource | back to attachment       |
