# complete_attachment_upload

> 这个 AirBuild MCP 工具对照声明的信息检查已上传的文件，并让附件可以发送。

Source: https://air.build/cn/docs/mcp-tools/complete_attachment_upload/

`complete_attachment_upload` 完成用 [create_attachment_upload](https://air.build/cn/docs/mcp-tools/create_attachment_upload/) 开始的上传：在你用 `PUT` 发送了字节之后，它会检查上传的文件大小和媒体类型是否与你声明的一致，并把附件标记为 `ready`。之后 [send_message](https://air.build/cn/docs/mcp-tools/send_message/) 才能附加它。它不上传任何内容，也不发送消息。对已就绪的附件再次调用，会按原样返回该附件。

| 只读 | 破坏性 | 幂等 |
| --- | --- | --- |
| 否 | 否 | 是 |

## 输入

| 输入 | 类型 | 必填 | 默认值 | 作用 |
| --- | --- | --- | --- | --- |
| `attachmentId` | 字符串（UUID） | 是 | — | 来自 [create_attachment_upload](https://air.build/cn/docs/mcp-tools/create_attachment_upload/) 的 `attachmentId` |

## 结果

| 字段 | 说明 |
| --- | --- |
| `attachment.id` | 附件的 ID |
| `attachment.fileName` | 文件名 |
| `attachment.mediaType` | 媒体类型，小写 |
| `attachment.byteCount` | 大小，以字节为单位 |
| `attachment.status` | `ready` |
| `attachment.altText` | 为看不到图片的人提供的图片描述，或 `null`（这个工具不设置） |

```json
{
  "attachment": {
    "id": "00000000-0000-0000-0000-000000000000",
    "fileName": "report.pdf",
    "mediaType": "application/pdf",
    "byteCount": 482113,
    "status": "ready",
    "altText": null
  }
}
```

## 错误

| 消息 | 何时出现 | 怎么办 |
| --- | --- | --- |
| The completed object does not match the Attachment upload declaration. | 上传文件的大小或 `Content-Type` 与声明的不一致，或字节被上传到了另一个上传任务 | 该附件会被丢弃：用 [create_attachment_upload](https://air.build/cn/docs/mcp-tools/create_attachment_upload/) 重新开始，并按给出的 `contentType` 发送与 `byteCount` 完全一致的字节 |
| The Attachment upload state cannot be completed. | 该上传已无法完成 | 用 [create_attachment_upload](https://air.build/cn/docs/mcp-tools/create_attachment_upload/) 重新开始 |
| The Attachment upload state changed before it became ready. | 在这次调用检查期间，另一次调用更改了该上传 | 再次调用；如果仍然失败，开始新的上传 |
| Attachment not found. | 没有附件使用这个 ID，或它已被丢弃 | 使用来自 [create_attachment_upload](https://air.build/cn/docs/mcp-tools/create_attachment_upload/) 的 `attachmentId` |
| Team not found. | 该附件属于你不在其中的团队 | 使用你所在团队的附件 |
| File uploads aren't available right now. Try again later. | 目前无法上传。 | 稍后再试 |

如果字节从未上传，AirBuild 找不到它们，调用会以存储错误失败：先完成 `PUT`。所有工具都可能返回的错误见 [服务器与登录](https://air.build/cn/docs/mcp-tools/server/#errors)。

## 示例

```json
{"name": "complete_attachment_upload", "arguments": {"attachmentId": "00000000-0000-0000-0000-000000000000"}}
```
