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

# 提取文件内容

文件上传成功后，就可以通过文件提取接口获取文件内容了。需要注意的是，极客智坊提供的是文件异步加载，所以需要轮询提取文件内容接口获取文件内容，直到获取到文件内容为止。

轮询时，可以通过响应数据中的 `status` 字段判断文件提取状态，`status=reading` 表示文件正在读取中，`status=done` 表示文件读取完成，此时可以通过 `content` 字段值获取文件内容，如果 `status=failed`，则表示文件读取失败。

### cURL 请求示例

```bash theme={null}
curl --location --request GET 'https://geekai.co/api/v1/file/27f9ab4d-137b-4bb3-bcca-ea28f2f89e95/content' \
--header 'Authorization: Bearer {$GEEKAI_API_KEY}' 
```

### Postman 请求响应示例

<img src="https://static.geekai.co/storage/2024/12/12/image-20241212193649116.png" className="mt-2" alt="提取文件内容" />


## OpenAPI

````yaml openapi.yaml GET /file/{uuid}/content
openapi: 3.1.0
info:
  title: 极客智坊 API文档
  description: 极客智坊 API 消息接口规范文档
  version: 1.0.0
servers:
  - url: https://geekai.co/api/v1
    description: 国内代理入口
  - url: https://geekai.dev/api/v1
    description: 海外代理入口
security:
  - bearerAuth: []
  - apiKeyAuth: []
paths:
  /file/{uuid}/content:
    get:
      tags:
        - Files
      summary: 获取文件内容
      description: 根据文件UUID获取文件内容，支持不同的返回格式和过滤选项。
      operationId: getFileContent
      parameters:
        - name: uuid
          in: path
          required: true
          description: 文件唯一标识符
          schema:
            type: string
            format: uuid
      responses:
        '200':
          description: 成功响应
          content:
            application/json:
              schema:
                type: object
                required:
                  - uuid
                  - status
                properties:
                  uuid:
                    type: string
                    format: uuid
                    description: 文件唯一ID,可通过该ID获取文件内容
                  name:
                    type: string
                    description: 文件名称
                  size:
                    type: integer
                    description: 文件大小
                  type:
                    type: string
                    description: 文件MIME类型
                  status:
                    type: string
                    description: '文件状态: pending（待处理）/reading（读取中）/failed（读取失败）/done（已读取）'
                    enum:
                      - pending
                      - reading
                      - processing
                      - failed
                      - done
                  md5:
                    type: string
                    description: 文件MD5值
                  url:
                    type: string
                    description: 文件URL地址
                  content:
                    type: string
                    description: 文件内容（只有status=done时，才会填充该字段）
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          description: 文件不存在
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/Error'
                  - example:
                      code: file_not_found
                      message: 指定的文件不存在
        '500':
          $ref: '#/components/responses/StandardError'
components:
  responses:
    Unauthorized:
      description: 未授权
      content:
        application/json:
          schema:
            type: object
            properties:
              code:
                type: string
                example: unauthorized
              message:
                type: string
                example: Invalid API key or token
    StandardError:
      description: 标准错误响应
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  schemas:
    Error:
      type: object
      required:
        - code
        - message
      properties:
        code:
          type: string
          description: 错误代码
          example: invalid_request
        message:
          type: string
          description: 错误信息描述
          example: 请求参数不合法
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: API认证token
    apiKeyAuth:
      type: apiKey
      in: header
      name: GeekAI-API-Key
      description: API密钥认证

````