File
sqlalchemy_file.base.BaseFile
Bases: dict[str, Any]
Base class for file object.
It keeps information on a content related to a specific storage. It is a specialized dictionary that provides also attribute style access, the dictionary parent permits easy encoding/decoding to JSON.
sqlalchemy_file.file.File
Bases: BaseFile
Takes a file as content and uploads it to the appropriate storage according to the attached Column and file information into the database as JSON.
Default attributes provided for all File include:
Attributes:
| Name | Type | Description |
|---|---|---|
filename |
str
|
This is the name of the uploaded file |
file_id |
str
|
This is the generated UUID for the uploaded file |
upload_storage |
str
|
Name of the storage used to save the uploaded file |
path |
str
|
This is a combination of |
content_type |
str
|
This is the content type of the uploaded file |
uploaded_at |
datetime
|
This is the upload date in ISO format |
url |
str
|
CDN url of the uploaded file |
file |
StoredFile
|
Only available for saved content, internally call
StorageManager.get_file()
on path and return an instance of |
apply_processors(processors, upload_storage=None)
Apply processors to current file.
apply_validators(validators, key='')
Apply validators to current file.
save_to_storage(upload_storage=None)
Save current file into provided upload_storage.
store_content(content, upload_storage=None, name=None, metadata=None, extra=None, headers=None, content_path=None)
Store content into provided upload_storage
with additional metadata. Can be used by processors
to store additional files.