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

> ## Agent Instructions
> For AgentScope Python, use https://docs.agentscope.io/stable/en/index for new projects. For existing projects, check the installed agentscope version and use matching versioned documentation.
> The /latest/ alias points to development documentation. Use it only with the matching development source. Do not mix AgentScope 1.x and 2.x APIs.
> State the AgentScope version when providing installation commands or code examples. ReMe uses its own continuously updated /reme/latest/ documentation.

# Fetch the original uploaded file of a document

> Stream the raw uploaded file back for preview or download.

Mirrors ``GET /workspace/files``: the body is piped chunk by chunk
from the blob store rather than read whole, so one large file
cannot exhaust the shared API process.  Only media types that
cannot carry script are served inline; everything else is forced
to an attachment.

Args:
    knowledge_base_id (`str`):
        The parent knowledge base.
    document_id (`str`):
        The document whose original file should be fetched.
    download (`bool`, defaults to ``False``):
        Force an attachment disposition.
    token (`str | None`, optional):
        Signed download token, accepted instead of ``X-User-ID``.
    x_user_id (`str | None`, optional):
        The normal identity header.
    service (`KnowledgeBaseService`):
        Injected knowledge base service.
    download_secret (`str`):
        Injected app-wide signing secret.

Returns:
    `StreamingResponse`:
        The file bytes with content-type / length / disposition
        headers derived from the upload-time record.



## OpenAPI

````yaml /en/versions/2.0.9/deploy/openapi.json get /knowledge_bases/{knowledge_base_id}/documents/{document_id}
openapi: 3.1.0
info:
  title: AgentScope
  version: 2.0.9
servers: []
security: []
paths:
  /knowledge_bases/{knowledge_base_id}/documents/{document_id}:
    get:
      tags:
        - knowledge_bases
      summary: Fetch the original uploaded file of a document
      description: |-
        Stream the raw uploaded file back for preview or download.

        Mirrors ``GET /workspace/files``: the body is piped chunk by chunk
        from the blob store rather than read whole, so one large file
        cannot exhaust the shared API process.  Only media types that
        cannot carry script are served inline; everything else is forced
        to an attachment.

        Args:
            knowledge_base_id (`str`):
                The parent knowledge base.
            document_id (`str`):
                The document whose original file should be fetched.
            download (`bool`, defaults to ``False``):
                Force an attachment disposition.
            token (`str | None`, optional):
                Signed download token, accepted instead of ``X-User-ID``.
            x_user_id (`str | None`, optional):
                The normal identity header.
            service (`KnowledgeBaseService`):
                Injected knowledge base service.
            download_secret (`str`):
                Injected app-wide signing secret.

        Returns:
            `StreamingResponse`:
                The file bytes with content-type / length / disposition
                headers derived from the upload-time record.
      operationId: >-
        read_knowledge_document_knowledge_bases__knowledge_base_id__documents__document_id__get
      parameters:
        - name: knowledge_base_id
          in: path
          required: true
          schema:
            type: string
            description: The knowledge base id.
            title: Knowledge Base Id
          description: The knowledge base id.
        - name: document_id
          in: path
          required: true
          schema:
            type: string
            description: The document id.
            title: Document Id
          description: The document id.
        - name: download
          in: query
          required: false
          schema:
            type: boolean
            description: Force a Content-Disposition attachment.
            default: false
            title: Download
          description: Force a Content-Disposition attachment.
        - name: token
          in: query
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            description: >-
              A token from ``POST .../documents/{document_id}/download_token``,
              accepted in place of the ``X-User-ID`` header so a browser
              navigation can fetch the file directly.
            title: Token
          description: >-
            A token from ``POST .../documents/{document_id}/download_token``,
            accepted in place of the ``X-User-ID`` header so a browser
            navigation can fetch the file directly.
        - name: x-user-id
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: X-User-Id
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema: {}
        '404':
          description: Not found
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError

````