cloudpathlib.S3Client¶
Bases: Client
Client class for AWS S3 which handles authentication with AWS for S3Path
instances. See documentation for the __init__
method
for detailed authentication options.
Source code in cloudpathlib/s3/s3client.py
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 196 197 198 199 200 201 202 203 204 205 206 207 208 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 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 |
|
Attributes¶
boto3_dl_extra_args = {k: vfor (k, v) in extra_args.items() if k in S3Transfer.ALLOWED_DOWNLOAD_ARGS}
instance-attribute
¶
boto3_list_extra_args = {k: self._extra_args[k]for k in ['RequestPayer', 'ExpectedBucketOwner'] if k in self._extra_args}
instance-attribute
¶
boto3_transfer_config = boto3_transfer_config
instance-attribute
¶
boto3_ul_extra_args = {k: vfor (k, v) in extra_args.items() if k in S3Transfer.ALLOWED_UPLOAD_ARGS}
instance-attribute
¶
client = self.sess.client('s3', endpoint_url=endpoint_url, config=Config(signature_version=botocore.session.UNSIGNED))
instance-attribute
¶
content_type_method = content_type_method
instance-attribute
¶
file_cache_mode = file_cache_mode
instance-attribute
¶
s3 = self.sess.resource('s3', endpoint_url=endpoint_url, config=Config(signature_version=botocore.session.UNSIGNED))
instance-attribute
¶
sess = boto3_session
instance-attribute
¶
Functions¶
CloudPath(cloud_path: Union[str, BoundedCloudPath]) -> BoundedCloudPath
¶
Source code in cloudpathlib/client.py
112 113 |
|
__init__(aws_access_key_id: Optional[str] = None, aws_secret_access_key: Optional[str] = None, aws_session_token: Optional[str] = None, no_sign_request: Optional[bool] = False, botocore_session: Optional[botocore.session.Session] = None, profile_name: Optional[str] = None, boto3_session: Optional[Session] = None, file_cache_mode: Optional[Union[str, FileCacheMode]] = None, local_cache_dir: Optional[Union[str, os.PathLike]] = None, endpoint_url: Optional[str] = None, boto3_transfer_config: Optional[TransferConfig] = None, content_type_method: Optional[Callable] = mimetypes.guess_type, extra_args: Optional[dict] = None)
¶
Class constructor. Sets up a boto3 Session
.
Directly supports the same authentication interface, as well as the same environment
variables supported by boto3. See boto3 Session documentation.
If no authentication arguments or environment variables are provided, then the client will be instantiated as anonymous, which will only have access to public buckets.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
aws_access_key_id
|
Optional[str]
|
AWS access key ID. |
None
|
aws_secret_access_key
|
Optional[str]
|
AWS secret access key. |
None
|
aws_session_token
|
Optional[str]
|
Session key for your AWS account. This is only needed when you are using temporarycredentials. |
None
|
no_sign_request
|
Optional[bool]
|
If |
False
|
botocore_session
|
Optional[Session]
|
An already instantiated botocore Session. |
None
|
profile_name
|
Optional[str]
|
Profile name of a profile in a shared credentials file. |
None
|
boto3_session
|
Optional[Session]
|
An already instantiated boto3 Session. |
None
|
file_cache_mode
|
Optional[Union[str, FileCacheMode]]
|
How often to clear the file cache; see the caching docs for more information about the options in cloudpathlib.eums.FileCacheMode. |
None
|
local_cache_dir
|
Optional[Union[str, PathLike]]
|
Path to directory to use as cache
for downloaded files. If None, will use a temporary directory. Default can be set with
the |
None
|
endpoint_url
|
Optional[str]
|
S3 server endpoint URL to use for the constructed boto3 S3 resource and client. Parameterize it to access a customly deployed S3-compatible object store such as MinIO, Ceph or any other. |
None
|
boto3_transfer_config
|
Optional[dict]
|
Instantiated TransferConfig for managing s3 transfers |
None
|
content_type_method
|
Optional[Callable]
|
Function to call to guess media type (mimetype) when
writing a file to the cloud. Defaults to |
guess_type
|
extra_args
|
Optional[dict]
|
A dictionary of extra args passed to download, upload, and list functions as relevant. You can include any keys supported by upload or download, and we will pass on only the relevant args. To see the extra args that are supported look at the upload and download lists in the boto3 docs. |
None
|
Source code in cloudpathlib/s3/s3client.py
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 |
|
clear_cache()
¶
Clears the contents of the cache folder. Does not remove folder so it can keep being written to.
Source code in cloudpathlib/client.py
115 116 117 118 119 120 121 122 123 124 |
|
get_default_client() -> Client
classmethod
¶
Get the default client, which the one that is used when instantiating a cloud path instance for this cloud without a client specified.
Source code in cloudpathlib/client.py
98 99 100 101 102 103 104 105 |
|
set_as_default_client() -> None
¶
Set this client instance as the default one used when instantiating cloud path instances for this cloud without a client specified.
Source code in cloudpathlib/client.py
107 108 109 110 |
|