> ## Documentation Index
> Fetch the complete documentation index at: https://docs.camel-ai.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Camel.storages.object storages.amazon s3

<a id="camel.storages.object_storages.amazon_s3" />

<a id="camel.storages.object_storages.amazon_s3.AmazonS3Storage" />

## AmazonS3Storage

```python theme={"system"}
class AmazonS3Storage(BaseObjectStorage):
```

A class to connect with AWS S3 object storage to put and get objects
from one S3 bucket. The class will first try to use the credentials passed
as arguments, if not provided, it will look for the environment variables
`AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY`. If none of these are
provided, it will try to use the local credentials (will be created if
logged in with AWS CLI).

**Parameters:**

* **bucket\_name** (str): The name of the S3 bucket.
* **create\_if\_not\_exists** (bool, optional): Whether to create the bucket if it does not exist. Defaults to True.
* **access\_key\_id** (Optional\[str], optional): The AWS access key ID. Defaults to None.
* **secret\_access\_key** (Optional\[str], optional): The AWS secret access key. Defaults to None.
* **anonymous** (bool, optional): Whether to use anonymous access. Defaults to False.
* **References**:
* **https**: //aws.amazon.com/pm/serv-s3/
* **https**: //aws.amazon.com/cli/

<a id="camel.storages.object_storages.amazon_s3.AmazonS3Storage.__init__" />

### **init**

```python theme={"system"}
def __init__(
    self,
    bucket_name: str,
    create_if_not_exists: bool = True,
    access_key_id: Optional[str] = None,
    secret_access_key: Optional[str] = None,
    anonymous: bool = False
):
```

<a id="camel.storages.object_storages.amazon_s3.AmazonS3Storage._prepare_and_check" />

### \_prepare\_and\_check

```python theme={"system"}
def _prepare_and_check(self):
```

Check privileges and existence of the bucket.

<a id="camel.storages.object_storages.amazon_s3.AmazonS3Storage.canonicalize_path" />

### canonicalize\_path

```python theme={"system"}
def canonicalize_path(file_path: PurePath):
```

Canonicalize file path for Amazon S3.

**Parameters:**

* **file\_path** (PurePath): The path to be canonicalized.

**Returns:**

Tuple\[str, str]: The canonicalized file key and file name.

<a id="camel.storages.object_storages.amazon_s3.AmazonS3Storage._put_file" />

### \_put\_file

```python theme={"system"}
def _put_file(self, file_key: str, file: File):
```

Put a file to the Amazon S3 bucket.

**Parameters:**

* **file\_key** (str): The path to the object in the bucket.
* **file** (File): The file to be uploaded.

<a id="camel.storages.object_storages.amazon_s3.AmazonS3Storage._get_file" />

### \_get\_file

```python theme={"system"}
def _get_file(self, file_key: str, filename: str):
```

Get a file from the Amazon S3 bucket.

**Parameters:**

* **file\_key** (str): The path to the object in the bucket.
* **filename** (str): The name of the file.

**Returns:**

File: The object from the S3 bucket.

<a id="camel.storages.object_storages.amazon_s3.AmazonS3Storage._upload_file" />

### \_upload\_file

```python theme={"system"}
def _upload_file(self, local_file_path: Path, remote_file_key: str):
```

Upload a local file to the Amazon S3 bucket.

**Parameters:**

* **local\_file\_path** (Path): The path to the local file to be uploaded.
* **remote\_file\_key** (str): The path to the object in the bucket.

<a id="camel.storages.object_storages.amazon_s3.AmazonS3Storage._download_file" />

### \_download\_file

```python theme={"system"}
def _download_file(self, local_file_path: Path, remote_file_key: str):
```

Download a file from the Amazon S3 bucket to the local system.

**Parameters:**

* **local\_file\_path** (Path): The path to the local file to be saved.
* **remote\_file\_key** (str): The key of the object in the bucket.

<a id="camel.storages.object_storages.amazon_s3.AmazonS3Storage._object_exists" />

### \_object\_exists

```python theme={"system"}
def _object_exists(self, file_key: str):
```

Check if the object exists in the Amazon S3 bucket.

**Parameters:**

* **file\_key**: The key of the object in the bucket.

**Returns:**

bool: Whether the object exists in the bucket.
