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

> 上传文件到指定知识库目录

# Upload Knowledge Files



## OpenAPI

````yaml post /v1/knowledge/{knowledge_id}/files
openapi: 3.1.0
info:
  title: spectra-server
  description: The API for Spectra Backend.
  version: 0.1.0
servers:
  - url: https://api-spectra.duplik.cn
security: []
paths:
  /v1/knowledge/{knowledge_id}/files:
    post:
      tags:
        - Knowledge
      summary: Upload Knowledge Files
      description: FileStorage or WebUrl Files Upload
      operationId: upload_knowledge_files_v1_knowledge__knowledge_id__files_post
      parameters:
        - name: knowledge_id
          in: path
          required: true
          schema:
            type: string
            title: Knowledge Id
        - name: user_id
          in: query
          required: false
          schema:
            type: string
            description: 用户ID
            title: User Id
          description: 用户ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/FileUpload'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Document'
                title: >-
                  Response Upload Knowledge Files V1 Knowledge  Knowledge Id 
                  Files Post
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Bad Request
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Unprocessable Entity
        '500':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Internal Server Error
      security:
        - HTTPBearer: []
components:
  schemas:
    FileUpload:
      properties:
        created_at:
          type: integer
          title: Created At
        updated_at:
          type: integer
          title: Updated At
        folder_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Folder Id
          description: folder id
        source_type:
          type: string
          enum:
            - file_storage
            - web
          title: Source Type
          description: file source, such as FILE_STORAGE, WEB
        files:
          items:
            $ref: '#/components/schemas/FileUploadBase'
          type: array
          maxItems: 100
          title: Files
          description: file list
        process_document:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Process Document
          description: whether process document
          default: true
        document_setting:
          anyOf:
            - $ref: '#/components/schemas/DocumentConfig'
            - type: 'null'
          description: process document with setting
      type: object
      required:
        - source_type
        - files
      title: FileUpload
      examples:
        - |

          {
              "files": [
                  {
                      "original_metadata": {
                          "file_name": "zemujia case.pdf",
                          "type": "application/pdf",
                          "byte_size": 2418879,
                          "source_type": "file_storage"
                      },
                      "url": "https://cos-qa-1252068037.cos.ap-beijing.myqcloud.com/org_id/648237335564370d02451d0-bde6-4cd6-9e5d-b65ba1709059.pdf"
                  }
              ],
              "folder_id": "",
              "knowledge_id": "648237335564370",
              "process_document": true,
              "document_setting": {
                  "pdf_parsing_mode": 2,
                  "audio_parsing_mode": 1,
                  "pdf_parsing_element_types": [
                      1,
                      2
                  ],
                  "smart_indexing_mode": 2,
                  "smart_indexing_enabled": true,
                  "overall_summarize_enabled": true
              },
              "source_type": "file_storage"
          }
    Document:
      properties:
        created_at:
          type: integer
          title: Created At
        updated_at:
          type: integer
          title: Updated At
        org_id:
          type: string
          maxLength: 20
          title: Org Id
        user_id:
          type: string
          maxLength: 20
          title: User Id
        overall_summarize_enabled:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Overall Summarize Enabled
          description: 'generate overall summary, 1: enabled, 2: disabled'
          default: true
        smart_indexing_mode:
          anyOf:
            - type: integer
            - type: 'null'
          title: Smart Indexing Mode
          description: 'smart indexing mode, 0: disabled, 1: standard, 2: advanced'
          default: 0
        smart_indexing_enabled:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Smart Indexing Enabled
          description: 'generate intelligent indexing, 1: enabled, 2: disabled'
          default: true
        split_media_enabled:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Split Media Enabled
          description: 'generate media segments, 1: enabled, 2: disabled'
          default: true
        pdf_parsing_mode:
          anyOf:
            - type: integer
            - type: 'null'
          title: Pdf Parsing Mode
          description: 'pdf parsing mode, 1: page, 2: section'
          default: 2
        pdf_parsing_element_types:
          anyOf:
            - items:
                type: integer
              type: array
            - type: 'null'
          title: Pdf Parsing Element Types
          description: 'pdf parsing element list, eg: [1, 2]. 1: table, 2: image, 3: formula'
          default:
            - 1
            - 2
        read_pdf_pages:
          anyOf:
            - type: string
            - type: 'null'
          title: Read Pdf Pages
          description: 'read pdf pages, Example: ''1,3,4'' or ''1,4-end'' or ''all'''
        audio_parsing_mode:
          anyOf:
            - type: integer
            - type: 'null'
          title: Audio Parsing Mode
          description: 'audio parsing mode, 1: transcript, 2: speaker diarization'
        audio_chunk_mode:
          anyOf:
            - type: integer
            - type: 'null'
          title: Audio Chunk Mode
          default: 1
        dataset_id:
          type: string
          title: Dataset Id
        file_id:
          type: string
          title: File Id
        name:
          anyOf:
            - type: string
              maxLength: 256
            - type: 'null'
          title: Name
        document_type:
          anyOf:
            - type: integer
            - type: 'null'
          title: Document Type
          default: 1
        next_step:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Next Step
          description: next step
          default: true
        llm:
          anyOf:
            - type: object
            - type: 'null'
          title: Llm
          default: {}
        metadata_info:
          type: object
          title: Metadata Info
          default: {}
        task_priority:
          anyOf:
            - type: integer
            - type: 'null'
          title: Task Priority
          description: task priority
        description:
          anyOf:
            - type: string
              maxLength: 512
            - type: 'null'
          title: Description
          default: ''
        summary:
          anyOf:
            - type: string
            - type: 'null'
          title: Summary
          default: ''
        step_status:
          anyOf:
            - type: integer
            - type: 'null'
          title: Step Status
          default: 100
        status:
          anyOf:
            - type: integer
            - type: 'null'
          title: Status
          default: 1
        process_status:
          anyOf:
            - type: integer
            - type: 'null'
          title: Process Status
          default: 100
        version:
          anyOf:
            - type: integer
            - type: 'null'
          title: Version
          default: 2
        splitter_type:
          anyOf:
            - type: integer
            - type: 'null'
          title: Splitter Type
          default: 1
        splitter:
          type: object
          title: Splitter
          default: {}
        sections:
          items:
            type: object
          type: array
          title: Sections
          default: []
        content_text:
          anyOf:
            - type: string
            - type: 'null'
          title: Content Text
          description: ''
        trim_text:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Trim Text
          description: ''
          default: true
        document_id:
          type: string
          title: Document Id
      type: object
      required:
        - org_id
        - user_id
        - dataset_id
        - file_id
        - document_id
      title: Document
    ErrorResponse:
      properties:
        code:
          type: integer
          title: Code
        message:
          type: string
          title: Message
      type: object
      required:
        - code
        - message
      title: ErrorResponse
    FileUploadBase:
      properties:
        url:
          type: string
          title: Url
          description: file_storage url or web url
        original_metadata:
          anyOf:
            - $ref: '#/components/schemas/FileMetadata'
            - type: 'null'
          description: if url from file_storage required
        document_metadata:
          anyOf:
            - type: object
            - type: 'null'
          title: Document Metadata
          description: document metadata
      type: object
      required:
        - url
      title: FileUploadBase
    DocumentConfig:
      properties:
        overall_summarize_enabled:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Overall Summarize Enabled
          description: 'generate overall summary, 1: enabled, 2: disabled'
          default: true
        smart_indexing_mode:
          anyOf:
            - type: integer
            - type: 'null'
          title: Smart Indexing Mode
          description: 'smart indexing mode, 0: disabled, 1: standard, 2: advanced'
          default: 0
        smart_indexing_enabled:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Smart Indexing Enabled
          description: 'generate intelligent indexing, 1: enabled, 2: disabled'
          default: true
        split_media_enabled:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Split Media Enabled
          description: 'generate media segments, 1: enabled, 2: disabled'
          default: true
        pdf_parsing_mode:
          anyOf:
            - type: integer
            - type: 'null'
          title: Pdf Parsing Mode
          description: 'pdf parsing mode, 1: page, 2: section'
          default: 2
        pdf_parsing_element_types:
          anyOf:
            - items:
                type: integer
              type: array
            - type: 'null'
          title: Pdf Parsing Element Types
          description: 'pdf parsing element list, eg: [1, 2]. 1: table, 2: image, 3: formula'
          default:
            - 1
            - 2
        read_pdf_pages:
          anyOf:
            - type: string
            - type: 'null'
          title: Read Pdf Pages
          description: 'read pdf pages, Example: ''1,3,4'' or ''1,4-end'' or ''all'''
        audio_parsing_mode:
          anyOf:
            - type: integer
            - type: 'null'
          title: Audio Parsing Mode
          description: 'audio parsing mode, 1: transcript, 2: speaker diarization'
        audio_chunk_mode:
          anyOf:
            - type: integer
            - type: 'null'
          title: Audio Chunk Mode
          default: 1
      type: object
      title: DocumentConfig
    FileMetadata:
      properties:
        file_name:
          anyOf:
            - type: string
            - type: 'null'
          title: File Name
        type:
          anyOf:
            - type: string
            - type: 'null'
          title: Type
        byte_size:
          anyOf:
            - type: integer
            - type: 'null'
          title: Byte Size
        source_type:
          anyOf:
            - type: string
            - type: 'null'
          title: Source Type
        location:
          anyOf:
            - type: string
            - type: 'null'
          title: Location
        source_location:
          anyOf:
            - type: string
            - type: 'null'
          title: Source Location
        path:
          anyOf:
            - type: string
            - type: 'null'
          title: Path
      type: object
      required:
        - file_name
        - type
        - byte_size
        - source_type
      title: FileMetadata
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

````