File
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.
Source code in sqlalchemy_file/base.py
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 |
Source code in sqlalchemy_file/file.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
|
apply_processors(processors, upload_storage=None)
Apply processors to current file.
apply_validators(validators, key='')
save_to_storage(upload_storage=None)
Save current file into provided upload_storage
.
Source code in sqlalchemy_file/file.py
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.