Storage Handler API¶
auris_tools.storageHandler.StorageHandler ¶
Source code in auris_tools/storageHandler.py
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 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 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 | |
__init__ ¶
Initialize the storage handler with AWS configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config |
An AWSConfiguration object, or None to use environment variables |
None
|
Source code in auris_tools/storageHandler.py
check_file_exists ¶
Check if a file exists in an S3 bucket.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bucket_name |
Bucket name |
required | |
object_name |
S3 object name (key) |
required |
Returns:
| Type | Description |
|---|---|
|
True if file exists, else False |
Source code in auris_tools/storageHandler.py
check_file_size ¶
Get the size of a file in an S3 bucket.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bucket_name |
Bucket name |
required | |
object_name |
S3 object name (key) |
required |
Returns:
| Type | Description |
|---|---|
|
File size in bytes or None if file doesn't exist |
Source code in auris_tools/storageHandler.py
delete_file ¶
Delete a file from an S3 bucket.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bucket_name |
Bucket name |
required | |
object_name |
S3 object name (key) |
required |
Returns:
| Type | Description |
|---|---|
|
True if file was deleted successfully, else False |
Source code in auris_tools/storageHandler.py
download_file ¶
Download a file from an S3 bucket.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bucket_name |
Bucket name |
required | |
object_name |
S3 object name (key) |
required | |
file_path |
Path where the file should be saved |
required |
Returns:
| Type | Description |
|---|---|
|
True if file was downloaded successfully, else False |
Source code in auris_tools/storageHandler.py
get_file_object ¶
Get a file object from an S3 bucket.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bucket_name |
Bucket name |
required | |
object_name |
S3 object name (key) |
required | |
as_bytes |
If True, return the content as bytes instead of a streaming object |
False
|
Returns:
| Type | Description |
|---|---|
|
S3 object (streaming) or bytes if as_bytes=True or None if not found |
Source code in auris_tools/storageHandler.py
list_files ¶
List files in an S3 bucket with optional prefix filtering.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bucket_name |
Bucket name |
required | |
prefix |
Prefix to filter objects (folder path) |
''
|
Returns:
| Type | Description |
|---|---|
|
List of object keys or empty list if error occurs |
Source code in auris_tools/storageHandler.py
upload_file ¶
Upload a file to an S3 bucket.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_path |
Path to the file to upload |
required | |
bucket_name |
Name of the bucket to upload to |
required | |
object_name |
S3 object name (key) |
required |
Returns:
| Type | Description |
|---|---|
|
True if file was uploaded successfully, else False |