Skip to main content

File

File attachment DocType.

Stores metadata about uploaded files. Actual file content
is stored via StorageAdapter (local, S3, GCS, etc.).

Attributes:
file_name: Original filename as uploaded
file_url: Storage URL/path for retrieval
file_size: Size in bytes
content_type: MIME type (e.g., "application/pdf")
attached_to_doctype: DocType this file is attached to
attached_to_name: Document ID this file is attached to
is_private: If True, requires authentication to access

Example:
file = File(
file_name="report.pdf",
file_url="/files/2024/01/report-abc123.pdf",
file_size=51200,
content_type="application/pdf",
is_private=True,
)

Source: file.py

Fields

FieldTypeRequiredDescriptionValidators
file_namestrOriginal filename-
file_urlstrStorage URL/path-
file_sizeintFile size in bytes-
content_typestrMIME type-
attached_to_doctypestrNoneDocType this file is attached to
attached_to_namestrNoneDocument ID this file is attached to
is_privateboolIf True, requires authentication-

Permissions

RoleCreateDeleteReadWrite
Guest
User

Configuration

SettingValue
SubmittableFalse
Track ChangesTrue

Controller

Controller hooks are implemented in *_controller.py files. Available lifecycle hooks:

  • validate() - Called before save, raise exceptions for validation errors
  • before_insert() - Called before inserting a new document
  • after_insert() - Called after successfully inserting
  • before_save() - Called before saving (insert or update)
  • after_save() - Called after saving
  • before_delete() - Called before deleting
  • after_delete() - Called after deleting