utils
konigle.utils
¶
Shared utilities for the Konigle SDK.
This module provides essential utility functions used throughout the SDK for file handling and URL construction.
FileInput
¶
Utility class for handling various file input types.
get_content_type(filename)
staticmethod
¶
Get MIME type for filename.
| PARAMETER | DESCRIPTION |
|---|---|
filename
|
Name of the file
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
MIME type string |
normalize(file_input, filename=None)
staticmethod
¶
Normalize various file input types to BytesIO with name attribute.
| PARAMETER | DESCRIPTION |
|---|---|
file_input
|
File input in various formats (path, bytes, file
TYPE:
|
filename
|
Optional filename to use if file_input doesn't have one
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Union[BinaryIO, BytesIO]
|
BytesIO object with name attribute set |
| RAISES | DESCRIPTION |
|---|---|
FileNotFoundError
|
If file path doesn't exist |
ValueError
|
If unsupported file input type |
build_url_path(*parts)
¶
Build URL path from parts, ensuring proper slash handling.
| PARAMETER | DESCRIPTION |
|---|---|
*parts
|
URL path components
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
Properly formatted URL path |
model_to_dict(model)
¶
Convert a Pydantic model to a dict, excluding None and unset fields and handling file fields appropriately for multipart requests.