diff --git a/README.md b/README.md index bb34f46..50e8a5a 100644 --- a/README.md +++ b/README.md @@ -112,8 +112,7 @@ body = b"I'm a byte encoded document" writer = S3Writer(client) # Submit a file to AWS S3 - -object_bytes = reader.read(bucket="my-bucket", key="Path/to/file", body=body) +writer.wite(bucket="my-bucket", key="Path/to/file", body=body) ``` #### Reading/Writing Combo Class diff --git a/src/driutils/io/aws.py b/src/driutils/io/aws.py index 20f7ba1..930338e 100644 --- a/src/driutils/io/aws.py +++ b/src/driutils/io/aws.py @@ -31,7 +31,7 @@ def __init__(self, s3_client: S3Client) -> None: class S3Reader(S3Base, ReaderInterface): """Class for handling file reads using the AWS S3 client""" - def read(self, bucket_name: str, s3_key: str) -> bytes: + def read(self, bucket_name: str, key: str) -> bytes: """ Retrieves an object from an S3 bucket. @@ -39,7 +39,7 @@ def read(self, bucket_name: str, s3_key: str) -> bytes: Args: bucket_name: The name of the S3 bucket. - s3_key: The key (path) of the object within the bucket. + key: The key (path) of the object within the bucket. Returns: bytes: raw bytes of the S3 object @@ -48,10 +48,10 @@ def read(self, bucket_name: str, s3_key: str) -> bytes: Exception: If there's any error in retrieving or parsing the object. """ try: - data = self._connection.get_object(Bucket=bucket_name, Key=s3_key) + data = self._connection.get_object(Bucket=bucket_name, Key=key) return data["Body"].read() except (RuntimeError, ClientError) as e: - logger.error(f"Failed to get {s3_key} from {bucket_name}") + logger.error(f"Failed to get {key} from {bucket_name}") logger.exception(e) raise e diff --git a/src/driutils/io/duckdb.py b/src/driutils/io/duckdb.py index 382cf5a..fffa818 100644 --- a/src/driutils/io/duckdb.py +++ b/src/driutils/io/duckdb.py @@ -97,7 +97,7 @@ def _authenticate(self, method: str, endpoint_url: Optional[str] = None, use_ssl def _auto_auth(self) -> None: """Automatically authenticates using environment variables""" logger.info("Initalized DuckDB with 'auto' secret") - + self._connection.install_extension("aws") self._connection.load_extension("aws") self._connection.execute(""" @@ -111,7 +111,7 @@ def _sts_auth(self) -> None: """Authenicates using assumed roles on AWS""" logger.info("Initalized DuckDB with 'sts' secret") - + self._connection.install_extension("aws") self._connection.load_extension("aws") self._connection.execute("""