THE ORIONIS API
Build with clarity.
Explore the building blocks of an async-first Python framework. Every module, class, and method — connected, searchable, and ready to build with.
class UploadedFile(IUploadedFile): (source)
Constructor: UploadedFile(filename, content_type, memory_threshold)
Hold an uploaded file in memory or spill it to a temporary file on disk.
| Parameters | |
| filename | Original name of the uploaded file as reported by the client. |
| content | MIME type declared by the client, or None if absent. |
| memory | Maximum in-memory bytes before spilling to disk (default 1 MiB). |
| Static Method | _sanitize |
Return a safe version of filename suitable for use on the filesystem. |
| Method | __del__ |
Release resources when the object is garbage collected. |
| Method | __init__ |
Initialize a new UploadedFile for an incoming multipart part. |
| Method | chunks |
Iterate over the file content in fixed-size chunks. |
| Method | close |
Close the file handle and release all associated resources. |
| Method | read |
Read the entire file content from the beginning. |
| Method | replace |
Replace the file content with data and update the byte counter. |
| Method | requires |
Determine whether the next write spills to the backing disk file. |
| Method | save |
Write the file contents to path on the local filesystem. |
| Method | write |
Append chunk to the file buffer. |
| Class Variable | __slots__ |
Declare the instance attribute slots reserved by this class. |
| Instance Variable | _extension |
Normalized extension derived from the uploaded filename. |
| Instance Variable | _file |
SpooledTemporaryFile spills to disk once memory_threshold is exceeded. |
| Instance Variable | _memory |
Maximum in-memory bytes before spilling to disk (default 1 MiB). |
| Instance Variable | _rolled |
Rolled flag used by UploadedFile. |
| Instance Variable | _size |
Size value used by UploadedFile. |
| Instance Variable | content |
MIME type declared by the client, or None if absent. |
| Instance Variable | filename |
Original name of the uploaded file as reported by the client. |
| Property | extension |
Return the file extension derived from filename, in lowercase. |
| Property | size |
Return the total number of bytes written so far. |
Return a safe version of filename suitable for use on the filesystem.
Strips null bytes, control characters, path separators, and Windows-reserved characters. Removes leading dots to prevent dotfile or path-traversal attacks. Falls back to "upload" when the sanitized result is empty.
| Parameters | |
filename:str | Raw filename as supplied by the client. |
| Returns | |
str | Sanitized filename safe for local persistence. |
Release resources when the object is garbage collected.
| Returns | |
None | Release resources when the object is garbage collected. |
str, content_type: str | None, memory_threshold: int = 1024 * 1024):
(source)
¶
Initialize a new UploadedFile for an incoming multipart part.
The filename is sanitized on ingestion: control characters, path separators, and Windows-reserved characters are stripped, and path-traversal sequences (leading dots) are removed. If the result is empty after sanitization the filename falls back to "upload".
| Parameters | |
filename:str | Original name of the uploaded file as reported by the client. |
contentstr or None | MIME type declared by the client, or None if absent. |
memoryint, optional | Maximum in-memory bytes before spilling to disk (default 1 MiB). |
| Returns | |
None | Initialize a new UploadedFile for an incoming multipart part. |
Close the file handle and release all associated resources.
SpooledTemporaryFile removes the backing temp file on close automatically, so no manual unlink is required.
| Returns | |
None | Close the file handle and release all associated resources. |
Replace the file content with data and update the byte counter.
Used internally after Content-Transfer-Encoding decoding (base64 or quoted-printable) to write the decoded payload back into the spooled buffer.
| Parameters | |
data:bytes | New file content that replaces whatever was previously written. |
| Returns | |
None | Replace the file content with data and update the byte counter. |
Write the file contents to path on the local filesystem.
Streams the data in _CHUNK_SIZE (64 KiB) chunks so that large uploads are never loaded entirely into memory.
| Parameters | |
path:str or pathlib.Path | Destination path for the saved file. |
| Returns | |
None | Write the file contents to path on the local filesystem. |
Append chunk to the file buffer.
Seek to the end before writing, including after a partial read. SpooledTemporaryFile spills to a real temp file on disk automatically once memory_threshold bytes are exceeded.
| Parameters | |
chunk:bytes | bytearray | memoryview | Raw bytes to append. |
| Returns | |
None | Append chunk to the file buffer. |
Return the file extension derived from filename, in lowercase.
| Returns | |
str | Lowercase suffix including the leading dot (e.g. ".png"). Empty string if the filename has no extension. |