Storage types
Bases: str
The file obect returned by the storage.
Source code in fastapi_storages/base.py
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 | |
name
property
File name including extension.
path
property
Complete file path.
size
property
File size in bytes.
delete()
Delete file from the storage
Source code in fastapi_storages/base.py
78 79 80 81 82 83 | |
open()
Open a file handle of the file.
Source code in fastapi_storages/base.py
61 62 63 64 65 66 | |
write(file)
Write input file which is opened in binary mode to destination.
Source code in fastapi_storages/base.py
68 69 70 71 72 73 74 75 76 | |
Bases: StorageFile
Inherits features of StorageFile and adds image specific properties.
Source code in fastapi_storages/base.py
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 | |
height
property
Image height in pixels.
width
property
Image width in pixels.
Bases: BaseStorage
File system storage which stores files in the local filesystem.
You might want to use this with the FileType type.
Source code in fastapi_storages/filesystem.py
8 9 10 11 12 13 14 15 16 17 18 19 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 | |
delete(name)
Delete the file from the filesystem.
Source code in fastapi_storages/filesystem.py
67 68 69 70 71 72 | |
get_name(name)
Get the normalized name of the file.
Source code in fastapi_storages/filesystem.py
20 21 22 23 24 25 | |
get_path(name)
Get full path to the file.
Source code in fastapi_storages/filesystem.py
27 28 29 30 31 32 | |
get_size(name)
Get file size in bytes.
Source code in fastapi_storages/filesystem.py
34 35 36 37 38 39 | |
open(name)
Open a file handle of the file object in binary mode.
Source code in fastapi_storages/filesystem.py
41 42 43 44 45 46 47 | |
write(file, name)
Write input file which is opened in binary mode to destination.
Source code in fastapi_storages/filesystem.py
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | |
Bases: BaseStorage
Amazon S3 or any S3 compatible storage backend.
You might want to use this with the FileType type.
Requires boto3 to be installed.
Source code in fastapi_storages/s3.py
15 16 17 18 19 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 | |
AWS_ACCESS_KEY_ID = os.environ.get('AWS_ACCESS_KEY_ID', '')
class-attribute
instance-attribute
AWS access key ID. Either set here or as an environment variable.
AWS_DEFAULT_ACL = ''
class-attribute
instance-attribute
Optional ACL set on the object like public-read.
By default file will be private.
AWS_QUERYSTRING_AUTH = False
class-attribute
instance-attribute
Indicate if query parameter authentication should be used in URLs.
AWS_S3_BUCKET_NAME = ''
class-attribute
instance-attribute
AWS S3 bucket name to use.
AWS_S3_CUSTOM_DOMAIN = ''
class-attribute
instance-attribute
Custom domain to use for serving object URLs.
AWS_S3_ENDPOINT_URL = ''
class-attribute
instance-attribute
AWS S3 endpoint URL.
AWS_S3_USE_SSL = True
class-attribute
instance-attribute
Indicate if SSL should be used.
AWS_SECRET_ACCESS_KEY = os.environ.get('AWS_SECRET_ACCESS_KEY', '')
class-attribute
instance-attribute
AWS secret access key. Either set here or as an environment variable.
delete(name)
Delete the file from S3
Source code in fastapi_storages/s3.py
123 124 125 126 127 128 | |
get_name(name)
Get the normalized name of the file.
Source code in fastapi_storages/s3.py
65 66 67 68 69 70 71 | |
get_path(name)
Get full URL to the file.
Source code in fastapi_storages/s3.py
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | |
get_size(name)
Get file size in bytes.
Source code in fastapi_storages/s3.py
98 99 100 101 102 103 104 105 106 | |
write(file, name)
Write input file which is opened in binary mode to destination.
Source code in fastapi_storages/s3.py
108 109 110 111 112 113 114 115 116 117 118 119 120 121 | |