---
sidebar:
  hidden: true
title: roboto.storage.object_store.s3
---
## Module Contents

### ProgressCallbackInvoker

```python
class roboto.storage.object_store.s3.ProgressCallbackInvoker(callback)
```

`from roboto.storage.object_store.s3 import ProgressCallbackInvoker`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/storage/object_store/s3.py#L35-L49)

Bases: `boto3.s3.transfer.BaseSubscriber`

Transfer subscriber that passes each progress update's byte count to a callback.

`S3Store.put` and `S3Store.get` report progress through it when given an `on_progress` callback, so most code never builds one.

**Parameters**

- **callback**: Function called with the number of bytes transferred since its previous call.

#### ProgressCallbackInvoker.on_progress()

```python
def on_progress(bytes_transferred, **kwargs)
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/storage/object_store/s3.py#L48-L49)

Callback to be invoked when progress is made on transfer

This callback can be useful for:

> - Recording and displaying progress

**Parameters**

- **future** (`s3transfer.futures.TransferFuture`): The TransferFuture representing the requested transfer.
- **bytes_transferred** (`int`): The number of bytes transferred for that invocation of the callback. Note that a negative amount can be provided, which usually indicates that an in-progress request needed to be retried and thus progress was rewound.

### S3Store

```python
class roboto.storage.object_store.s3.S3Store(
    s3_client: botocore.client.BaseClient,
    transfer_config: Optional[boto3.s3.transfer.TransferConfig] = None,
)
```

`from roboto.storage.object_store import S3Store`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/storage/object_store/s3.py#L53-L174)

Bases: [`roboto.storage.object_store.object_store.ObjectStore`](/docs/reference/python-sdk/roboto/storage/object_store/object_store#roboto.storage.object_store.object_store.ObjectStore)

Object store that copies files to and from Amazon S3, selected for `s3://` URIs.

[`get_store_for_uri()`](/docs/reference/python-sdk/roboto/storage/object_store/registry#roboto.storage.object_store.registry.StoreRegistry.get_store_for_uri) builds one through `create`, so most code never builds one. Use it as a context manager: leaving the `with` block waits for every upload and download started in it to finish.

**Parameters**

- **s3_client** (`botocore.client.BaseClient`): boto3 S3 client to transfer with.
- **transfer_config** (`Optional[boto3.s3.transfer.TransferConfig]`): Thread and part-size settings for transfers. `None` uses boto3's defaults.

#### S3Store.create()

```python
@classmethod
def create(
    credential_provider: roboto.storage.object_store.object_store.CredentialProvider,
    **kwargs,
) -> S3Store
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/storage/object_store/s3.py#L66-L122)

Build an S3 store that fetches new credentials from Roboto before the current ones expire.

[`get_store_for_uri()`](/docs/reference/python-sdk/roboto/storage/object_store/registry#roboto.storage.object_store.registry.StoreRegistry.get_store_for_uri) builds stores for `s3://` URIs through it, so most code never calls it. The store transfers on up to twice as many threads as the machine has CPUs, and at least 10. When the first credentials set `send_requests_to`, the store sends each request to the URL of the credentials that signed it, as [`send_requests_to`](/docs/reference/python-sdk/roboto/storage/credentials#roboto.storage.credentials.RobotoCredentials.send_requests_to) describes, and a request signed with credentials older than the two most recent raises `RuntimeError` when it is sent.

**Parameters**

- **credential_provider** (`roboto.storage.object_store.object_store.CredentialProvider`): Function that fetches temporary credentials from Roboto. Called once here, for the first credentials and their region, and again whenever the current credentials near their expiry.
- **`\*\*kwargs`**: Ignored.

**Returns**

- `S3Store`

#### S3Store.get()

```python
def get(
    source_uri: str,
    destination: pathlib.Path,
    on_progress: Optional[roboto.storage.object_store.object_store.OnProgress] = None,
) -> roboto.storage.object_store.object_store.FutureLike[None]
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/storage/object_store/s3.py#L156-L174)

Start downloading the object at a URI in the store to a local file.

Creates any parent directories of `destination` that do not exist.

**Parameters**

- **source_uri** (`str`): Full URI to download from, such as `s3://<bucket>/<key>`.
- **destination** (`pathlib.Path`): Local path to write the file to.
- **on_progress** (`Optional[roboto.storage.object_store.object_store.OnProgress]`): Function called with the number of bytes downloaded since its previous call. `None` reports no progress.

**Returns**

- `roboto.storage.object_store.object_store.FutureLike[None]`: Future that resolves to `None` when the download finishes, or raises the exception it failed with.

#### S3Store.put()

```python
def put(
    source: pathlib.Path,
    destination_uri: str,
    on_progress: Optional[roboto.storage.object_store.object_store.OnProgress] = None,
) -> roboto.storage.object_store.object_store.FutureLike[None]
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/storage/object_store/s3.py#L138-L154)

Start uploading a local file to a URI in the store.

**Parameters**

- **source** (`pathlib.Path`): Path of the local file to upload.
- **destination_uri** (`str`): Full URI to upload to, such as `s3://<bucket>/<key>`.
- **on_progress** (`Optional[roboto.storage.object_store.object_store.OnProgress]`): Function called with the number of bytes uploaded since its previous call. `None` reports no progress.

**Returns**

- `roboto.storage.object_store.object_store.FutureLike[None]`: Future that resolves to `None` when the upload finishes, or raises the exception it failed with.
