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

# Download File

> Preview or download uploaded files previously uploaded via the [Upload File](/api-reference/files/upload-file) API. Files can only be accessed if they belong to messages within the requesting application.



## OpenAPI

````yaml /en/api-reference/openapi_completion.json get /files/{file_id}/preview
openapi: 3.0.1
info:
  title: Completion App API
  description: >-
    The text generation application offers non-session support and is ideal for
    translation, article writing, summarization AI, and more.
  version: 1.0.0
servers:
  - url: '{api_base_url}'
    description: >-
      The base URL for the Completion App API. Replace {api_base_url} with the
      actual API base URL provided for your application.
    variables:
      api_base_url:
        default: https://api.dify.ai/v1
        description: Actual base URL of the API
security:
  - ApiKeyAuth: []
tags:
  - name: Completions
    description: Operations related to text generation and completion.
  - name: Files
    description: Operations related to file management.
  - name: End Users
    description: Operations related to end user information.
  - name: Feedback
    description: Operations related to user feedback.
  - name: TTS
    description: Operations related to Text-to-Speech and Speech-to-Text.
  - name: Applications
    description: Operations to retrieve application settings and information.
paths:
  /files/{file_id}/preview:
    get:
      tags:
        - Files
      summary: Download File
      description: >-
        Preview or download uploaded files previously uploaded via the [Upload
        File](/api-reference/files/upload-file) API. Files can only be accessed
        if they belong to messages within the requesting application.
      operationId: previewCompletionFile
      parameters:
        - name: file_id
          in: path
          required: true
          description: >-
            The unique identifier of the file to preview, obtained from the
            [Upload File](/api-reference/files/upload-file) API response.
          schema:
            type: string
            format: uuid
        - name: as_attachment
          in: query
          required: false
          description: >-
            If `true`, forces the file to download as an attachment instead of
            previewing in browser.
          schema:
            type: boolean
            default: false
        - name: user
          in: query
          required: false
          description: User identifier, used for end-user context.
          schema:
            type: string
      responses:
        '200':
          description: >-
            Returns the raw file content. The `Content-Type` header is set to
            the file's MIME type. If `as_attachment` is `true`, the file is
            returned as a download with `Content-Disposition: attachment`.
          content:
            application/octet-stream:
              schema:
                type: string
                format: binary
        '403':
          description: '`file_access_denied` : Access to the requested file is denied.'
          content:
            application/json:
              examples:
                file_access_denied:
                  summary: file_access_denied
                  value:
                    status: 403
                    code: file_access_denied
                    message: Access to the requested file is denied.
        '404':
          description: '`file_not_found` : The requested file was not found.'
          content:
            application/json:
              examples:
                file_not_found:
                  summary: file_not_found
                  value:
                    status: 404
                    code: file_not_found
                    message: The requested file was not found.
components:
  securitySchemes:
    ApiKeyAuth:
      type: http
      scheme: bearer
      bearerFormat: API_KEY
      description: >-
        API Key authentication. For all API requests, include your API Key in
        the `Authorization` HTTP Header, prefixed with `Bearer `. Example:
        `Authorization: Bearer {API_KEY}`. **Strongly recommend storing your API
        Key on the server-side, not shared or stored on the client-side, to
        avoid possible API-Key leakage that can lead to serious consequences.**

````