> ## Documentation Index
> Fetch the complete documentation index at: https://docs.qoder.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 下载文件内容

> 获取文件内容的预签名下载 URL。

`GET /api/v1/cloud/files/{file_id}/content`

返回 [File content link](/zh/cloud-agents/api/files/schemas#file-content-link)。返回的 URL 有时效性，可用于直接下载文件内容。

只有 File 对象的 `downloadable` 字段为 `true` 时才可下载。

## 请求头

| 头部              | 必选 | 说明             |
| --------------- | -- | -------------- |
| `Authorization` | 是  | `Bearer <PAT>` |

## 路径参数

| 参数        | 类型     | 必选 | 说明                  |
| --------- | ------ | -- | ------------------- |
| `file_id` | string | 是  | File ID，前缀为 `file_` |

## 示例请求

```bash theme={null}
curl -X GET "https://api.qoder.com/api/v1/cloud/files/file_019e3bb9b0c2752688aeb5fdacf00565/content" \
  -H "Authorization: Bearer $QODER_PAT"
```

## 示例响应

**HTTP 200 OK**

```json theme={null}
{
  "expires_at": "2026-05-18T16:34:52Z",
  "url": "https://storage.qoder.com/files/..."
}
```

## 响应字段

| 字段           | 类型     | 说明                         |
| ------------ | ------ | -------------------------- |
| `url`        | string | 预签名下载 URL                  |
| `expires_at` | string | URL 的 UTC 过期时间，RFC 3339 格式 |

## 注意事项

* `expires_at` 之后需要重新请求下载 URL。
* 客户端需要先解析 JSON 响应，读取 `url` 字段，再对该 URL 发起 GET 请求。

## 错误码

| HTTP | type                   | 触发条件                 |
| ---- | ---------------------- | -------------------- |
| 401  | `authentication_error` | 缺少或无效的认证令牌           |
| 403  | `permission_error`     | 文件不可通过 `/content` 下载 |
| 404  | `not_found_error`      | 指定 ID 的文件不存在         |
| 409  | `conflict_error`       | 文件存在但状态不是 `ready`    |
| 410  | `not_found_error`      | 文件处于 `deleted` 状态    |

完整错误信封说明详见 [错误参考](/zh/cloud-agents/api/conventions/errors)。

## 相关

<CardGroup cols={2}>
  <Card title="附加与下载文件" icon="paperclip" href="/zh/cloud-agents/files">
    上传文件为 Agent 提供上下文，并下载 Agent 产出的文件。
  </Card>
</CardGroup>
