Overview
The Contextbase Python SDK provides theContextbaseFile class for seamless file handling. It automatically manages MIME type detection, Base64 encoding, and file operations.
ContextbaseFile Class
Creating Files
From File Path
From String Content
From Binary Content
Direct Constructor
File Operations
Access File Properties
File Comparison
Publishing Files
Using publish_file() (Recommended)
The simplest way to upload files:Using publish() with ContextbaseFile
For more control over file handling:Supported File Types
The SDK automatically detects MIME types for common extensions:| Category | Extensions | MIME Types |
|---|---|---|
| Documents | .pdf, .doc, .docx, .txt, .md | application/pdf, text/plain, etc. |
| Images | .png, .jpg, .jpeg, .gif, .svg | image/png, image/jpeg, etc. |
| Data | .csv, .json, .xml, .yaml | text/csv, application/json, etc. |
| Code | .py, .js, .html, .css | text/x-python, text/javascript, etc. |
| Archives | .zip, .tar, .gz | application/zip, etc. |
- String content: Defaults to
text/plain - Binary content: Defaults to
application/octet-stream
