Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Infiniflow Ragflow UseUploadDocument Hook

From Leeroopedia
Knowledge Sources
Domains Frontend, Knowledge_Base
Last Updated 2026-02-12 06:00 GMT

Overview

Upload hook with auto-parse capability that handles file upload, optional automatic parsing, and unsupported file type detection.

Description

useHandleUploadDocument manages the document upload modal state and orchestrates the upload flow. On submit, it calls uploadDocument with the file list, then optionally triggers runDocumentByIds if parseOnCreation is true and the upload succeeded. It uses getUnSupportedFilesCount to detect partial failures where some file types are unsupported (HTTP 500 with partial success). The modal is hidden only when the effective result code is 0 (full or partial success). The hook returns loading state, modal visibility controls, and the submit handler.

Usage

Consumed by the dataset page upload button to handle the complete file upload workflow including validation and optional auto-parsing.

Code Reference

Source Location

Signature

export const useHandleUploadDocument = () => {
  documentUploadLoading, onDocumentUploadOk, documentUploadVisible,
  hideDocumentUploadModal, showDocumentUploadModal,
};

Import

import { useHandleUploadDocument } from './use-upload-document';

I/O Contract

Inputs

Name Type Required Description
(none) - - Hook manages state internally

Outputs

Name Type Description
onDocumentUploadOk function Submit handler accepting { fileList, parseOnCreation }
documentUploadLoading boolean Upload in progress
showDocumentUploadModal function Open upload dialog

Usage Examples

const { showDocumentUploadModal, onDocumentUploadOk, documentUploadLoading } = useHandleUploadDocument();

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment