Skip to content

FileData

Per-file upload result. A Pydantic model — serializes cleanly to JSON.

Fields

Field Type Description
field_name str Form field this file was submitted under
filename str \| None Final stored filename
original_filename str \| None Filename as submitted by the client
content_type str \| None MIME type reported by client
size int \| None File size in bytes
path Path \| None Absolute local path (local engine only)
url str \| None Public URL, when derivable
key str \| None Object key (cloud) or destination-relative path (local)
status bool True on success, False on failure
error str \| None Error message (when status=False)
storage str \| None Backend name ("local", "memory", "s3", "gcs", "azure")
metadata dict[str, Any] Per-file metadata from callbacks and backends
file bytes \| None Raw bytes (memory engine only) — excluded from serialization

Properties

location

Returns the most useful persisted location — url, then path, then key:

file_data.location

__bool__

bool(file_data) mirrors file_data.status:

if file_data:
    print("uploaded")

Serialization

Standard Pydantic:

file_data.model_dump(mode="json")
# {
#     "field_name": "avatar",
#     "filename": "photo.jpg",
#     "path": "/app/uploads/photo.jpg",   # Path → str
#     "key": "photo.jpg",
#     "size": 1048576,
#     "status": True,
#     ...                                  # "file" bytes are omitted
# }

FileData.key is the handle for later engine operations — engine.delete(key) and engine.presign_download(key).