Writer¶
Writer(base_path, *, concurrency_limit=CONCURRENCY_LIMIT)
¶
Asynchronous file writer for streamed content.
Provides controlled, concurrent-safe persistence of streamed file chunks to the local filesystem. Files are written using positional writes and remain open for the lifetime of the writer instance.
All target paths are resolved relative to a fixed base directory. Path traversal outside of this directory is explicitly rejected.
save(stream)
async
¶
Persists streamed content to disk.
Consumes a content stream and writes its chunks to disk using positional writes. Chunks may arrive out of order but are written according to their declared offsets.
All file paths are resolved against the writer base directory. Attempts to escape this directory are rejected.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stream
|
ContentStream
|
Stream yielding file chunks with path, content, and offset. |
required |
Raises:
| Type | Description |
|---|---|
PermissionError
|
If a resolved file path escapes the base directory. |