> ## 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.

# File データ構造

> File API の共通構造、アップロード制約。

## File オブジェクト

upload、get、list エンドポイントで File オブジェクトが返却されます。

| フィールド          | 型              | 説明                                                                         |
| -------------- | -------------- | -------------------------------------------------------------------------- |
| `id`           | string         | `file_` プレフィックス付きの File ID                                                 |
| `type`         | string         | 常に `"file"`                                                                |
| `filename`     | string         | 保存されたファイル名                                                                 |
| `size_bytes`   | integer        | ファイルサイズ（バイト）                                                               |
| `mime_type`    | string         | アップロード時に指定された、またはファイル名から検出された MIME タイプ                                     |
| `downloadable` | boolean        | このファイルを `GET /api/v1/cloud/files/{file_id}/content` 経由でダウンロードできるかどうか       |
| `scope`        | object \| null | 他のリソースに関連付けられている場合のスコープオブジェクト。例: `{ "id": "sess_...", "type": "session" }` |
| `metadata`     | object         | アップロード時に指定するカスタムメタデータオブジェクト。デフォルトは `{}`                                    |
| `created_at`   | string         | RFC 3339 形式の UTC 作成時刻                                                      |

## ファイルコンテンツリンク

`GET /api/v1/cloud/files/{file_id}/content` はこのオブジェクトを返します。

| フィールド        | 型      | 説明                           |
| ------------ | ------ | ---------------------------- |
| `url`        | string | 署名付きダウンロード URL               |
| `expires_at` | string | RFC 3339 形式の UTC での URL 有効期限 |

## アップロードフォームフィールド

`POST /api/v1/cloud/files` は `multipart/form-data` を使用します。

| フィールド      | 型           | 必須  | 説明                                                                               |
| ---------- | ----------- | --- | -------------------------------------------------------------------------------- |
| `file`     | file        | はい  | テキストベースのファイルコンテンツ                                                                |
| `name`     | string      | いいえ | 保存されるファイル名。デフォルトはアップロードされたファイル名。サーバーのサニタイズ後、長さは 1-255 バイトで、`.` または `..` は使用できません |
| `metadata` | JSON string | いいえ | フォームフィールドとしてエンコードされた有効な JSON。最大生データ長は 8 KB。デフォルトは `{}`                           |

## サポートされるアップロードファイルタイプ

アップロードエンドポイントはテキストベースのファイルのみを受け付けます。

| カテゴリ       | 受け入れ可能な値                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| ---------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| MIME タイプ   | すべての `text/*` MIME タイプに加え、`application/json`、`application/xml`、`application/javascript`、`application/x-yaml`、`application/x-toml`                                                                                                                                                                                                                                                                                                                                                                                                                    |
| 拡張子        | `.txt`, `.md`, `.csv`, `.json`, `.xml`, `.yaml`, `.yml`, `.toml`, `.ini`, `.conf`, `.cfg`, `.env`, `.log`, `.html`, `.htm`, `.css`, `.scss`, `.less`, `.js`, `.jsx`, `.ts`, `.tsx`, `.vue`, `.svelte`, `.py`, `.go`, `.rs`, `.java`, `.kt`, `.scala`, `.c`, `.cpp`, `.cc`, `.h`, `.hpp`, `.rb`, `.php`, `.swift`, `.r`, `.lua`, `.pl`, `.sh`, `.bash`, `.zsh`, `.fish`, `.ps1`, `.sql`, `.graphql`, `.gql`, `.proto`, `.dockerfile`, `.makefile`, `.gitignore`, `.editorconfig`, `.eslintrc`, `.prettierrc`, `.tex`, `.rst`, `.adoc`, `.org`, `.svg` |
| 拡張子なしファイル名 | `dockerfile`, `makefile`, `gemfile`, `rakefile`, `procfile`, `vagrantfile`, `justfile`, `brewfile`                                                                                                                                                                                                                                                                                                                                                                                                                                                   |

## 関連項目

<CardGroup cols={2}>
  <Card title="ファイルの添付とダウンロード" icon="paperclip" href="/ja/cloud-agents/files">
    Agent にコンテキストを提供するファイルをアップロードし、Agent が生成したファイルをダウンロードします。
  </Card>
</CardGroup>
