cosmotech.coal.aws.s3¶
s3
¶
S3 bucket operations module.
This module provides functions for interacting with S3 buckets, including uploading, downloading, and deleting files.
create_s3_client(endpoint_url, access_id, secret_key, use_ssl=True, ssl_cert_bundle=None)
¶
Create an S3 client with the given credentials and configuration.
Args: endpoint_url: The S3 endpoint URL access_id: The AWS access key ID secret_key: The AWS secret access key use_ssl: Whether to use SSL for the connection ssl_cert_bundle: Path to the SSL certificate bundle
Returns: An S3 client object
Source code in cosmotech/coal/aws/s3.py
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 |
|
create_s3_resource(endpoint_url, access_id, secret_key, use_ssl=True, ssl_cert_bundle=None)
¶
Create an S3 resource with the given credentials and configuration.
Args: endpoint_url: The S3 endpoint URL access_id: The AWS access key ID secret_key: The AWS secret access key use_ssl: Whether to use SSL for the connection ssl_cert_bundle: Path to the SSL certificate bundle
Returns: An S3 resource object
Source code in cosmotech/coal/aws/s3.py
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 |
|
delete_objects(bucket_name, s3_resource, file_prefix=None)
¶
Delete objects from an S3 bucket, optionally filtered by prefix.
Args: bucket_name: Name of the S3 bucket s3_resource: S3 resource object file_prefix: Optional prefix to filter objects to delete
Source code in cosmotech/coal/aws/s3.py
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 |
|
download_files(target_folder, bucket_name, s3_resource, file_prefix=None)
¶
Download files from an S3 bucket to a local folder.
Args: target_folder: Local folder to download files to bucket_name: Name of the S3 bucket s3_resource: S3 resource object file_prefix: Optional prefix to filter objects to download
Source code in cosmotech/coal/aws/s3.py
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 |
|
upload_data_stream(data_stream, bucket_name, s3_client, file_name, file_prefix='')
¶
Upload a data stream to an S3 bucket.
Args: data_stream: BytesIO stream containing the data to upload bucket_name: Name of the S3 bucket s3_client: S3 client object file_name: Name of the file to create in the bucket file_prefix: Prefix to add to the file name in the bucket
Source code in cosmotech/coal/aws/s3.py
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 |
|
upload_file(file_path, bucket_name, s3_resource, file_prefix='')
¶
Upload a single file to an S3 bucket.
Args: file_path: Path to the file to upload bucket_name: Name of the S3 bucket s3_resource: S3 resource object file_prefix: Prefix to add to the file name in the bucket
Source code in cosmotech/coal/aws/s3.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
|
upload_folder(source_folder, bucket_name, s3_resource, file_prefix='', recursive=False)
¶
Upload files from a folder to an S3 bucket.
Args: source_folder: Path to the folder containing files to upload bucket_name: Name of the S3 bucket s3_resource: S3 resource object file_prefix: Prefix to add to the file names in the bucket recursive: Whether to recursively upload files from subdirectories
Source code in cosmotech/coal/aws/s3.py
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 |
|