Skip to main content

documents.upload_file

Uploads a file to a text namespace. The SDK automatically requests a pre-signed upload URL, uploads the file bytes, and the backend processes and embeds the content asynchronously.

Parameters

str
required
The name of the target text namespace.
str | Path | BinaryIO
required
Path to a local file (str or Path) or a file-like object (BinaryIO).
Returns: Dict[str, Any] - A dictionary confirming the file upload request. Common response fields include success, message, namespace, file_name, and file_size. Raises: NamespaceNotFound, InvalidInputError, AuthenticationError, APIError, MoorchehError.

Example

Upload File Example

Input Options

You can pass either a file path or a file-like object.
File Path Or File-Like Object

Complete Example

Complete File Upload Workflow

Important Notes

SDK handles pre-signed upload internally: You do not need to call the upload URL endpoint manually when using documents.upload_file.
Asynchronous Processing: Uploaded files are processed asynchronously. Allow some time after upload before searching.
Supported file types only: .pdf, .docx, .xlsx, .json, .txt, .csv, .md.
File size limit: Maximum upload size is 5GB.

Best Practices

  • Use clear, stable file names so ingestion and auditing are easier
  • Keep source files clean and well-structured for better extraction quality
  • Use markdown or plain text when possible for predictable parsing
  • Upload large datasets in multiple files rather than one huge file
  • Wait briefly before running search queries after upload
  • Handle upload exceptions and retry transient failures

File Limits

  • File Size: Max 5GB
  • Supported Types: .pdf, .docx, .xlsx, .json, .txt, .csv, .md
  • Upload URL Expiry: Internally handled by SDK (short-lived pre-signed URL)
  • List Files - List raw objects in storage for a namespace
  • Delete Files - Remove file objects by name from storage
  • Fetch Text Data - List ingested text and summary chunks
  • Search - Query uploaded and processed content
  • Delete Data - Remove documents or entries from a namespace