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__ |
Undocumented |
| Instance Variable | _extension |
Undocumented |
| Instance Variable | _file |
Undocumented |
| Instance Variable | _memory |
Undocumented |
| Instance Variable | _rolled |
Undocumented |
| Instance Variable | _size |
Undocumented |
| Instance Variable | content |
Undocumented |
| Instance Variable | filename |
Undocumented |
| 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. |
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 | Undocumented |
Iterate over the file content in fixed-size chunks.
Rewinds the buffer and yields consecutive chunks so large uploads can be consumed without loading everything in memory.
| Parameters | |
size:int | Maximum number of bytes per yielded chunk. |
| Returns | |
Iterator[ | Undocumented |
| Yields | |
bytes | Consecutive chunks from the beginning of the content. |
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 | Undocumented |
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 | Undocumented |
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 | Undocumented |
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. |