s3_utils
Utility module for S3 operations related to Copernicus Data Space Ecosystem.
get_s3_client #
get_s3_client(endpoint_url: str | None = None) -> client
Creates and returns a boto3 S3 client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
endpoint_url
|
str | None
|
The S3 endpoint URL. If None, it attempts to use the COPERNICUS_S3_ENDPOINT environment variable. |
None
|
Returns:
| Type | Description |
|---|---|
client
|
A boto3 S3 client. |
Source code in src/geospatial_tools/s3_utils.py
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 | |
parse_s3_url #
parse_s3_url(url: str) -> tuple[str, str]
Parses an S3 URL or a CDSE STAC href to extract the bucket and key.
Expected formats: - s3://bucket/key - https://eodata.dataspace.copernicus.eu/bucket/key - https://zipper.dataspace.copernicus.eu/download/uuid (this might not be a direct S3 key)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
The URL to parse. |
required |
Returns:
| Type | Description |
|---|---|
tuple[str, str]
|
A tuple of (bucket, key). |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the URL cannot be parsed into a bucket and key. |
Source code in src/geospatial_tools/s3_utils.py
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 | |