---
sidebar:
  label: roboto.storage.file_service
  order: 4
title: roboto.storage.file_service
---
## Module Contents

### FileService

```python
class roboto.storage.file_service.FileService(
    roboto_client: Optional[roboto.http.RobotoClient] = None,
    object_store_registry: Optional[roboto.storage.object_store.StoreRegistry] = None,
)
```

`from roboto.storage import FileService`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/storage/file_service.py#L37-L207)

Application service for performing upload and download to the Roboto Platform.

Agnostic to object store provider.

**Parameters**

- **roboto_client** (`Optional[roboto.http.RobotoClient]`)
- **object_store_registry** (`Optional[roboto.storage.object_store.StoreRegistry]`)

#### FileService.download()

```python
def download(
    files: collections.abc.Sequence[roboto.storage.download_session.DownloadableFile],
    association: roboto.association.Association,
    caller_org_id: Optional[str] = None,
    on_progress: Optional[roboto.storage.object_store.OnProgress] = None,
) -> None
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/storage/file_service.py#L148-L207)

Download files from the Roboto Platform.

**Parameters**

- **files** (`collections.abc.Sequence[roboto.storage.download_session.DownloadableFile]`): Sequence of files to download, each with source_uri and destination_path.
- **association** (`roboto.association.Association`): Association of the files to download.
- **caller_org_id** (`Optional[str]`): Optional organization ID for cross-org access.
- **on_progress** (`Optional[roboto.storage.object_store.OnProgress]`): Optional callback to be periodically called with the number of bytes downloaded.

**Returns**

- `None`

#### FileService.upload()

```python
def upload(
    files: collections.abc.Iterable[pathlib.Path],
    association: roboto.association.Association,
    destination_paths: collections.abc.Mapping[pathlib.Path, str] = {},
    batch_size: int = _DEFAULT_UPLOAD_BATCH_SIZE,
    device_id: Optional[str] = None,
    caller_org_id: Optional[str] = None,
    on_progress: Optional[roboto.storage.object_store.OnProgress] = None,
) -> dict[pathlib.Path, str]
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/storage/file_service.py#L51-L146)

Upload the given files and return which file record each one created.

**Parameters**

- **files** (`collections.abc.Iterable[pathlib.Path]`)
- **association** (`roboto.association.Association`)
- **destination_paths** (`collections.abc.Mapping[pathlib.Path, str]`)
- **batch_size** (`int`)
- **device_id** (`Optional[str]`)
- **caller_org_id** (`Optional[str]`)
- **on_progress** (`Optional[roboto.storage.object_store.OnProgress]`)

**Returns**

- `dict[pathlib.Path, str]`: Mapping from each uploaded local path to the ID of the file record it created.

**Raises**

- `ValueError`: If two of the given files resolve to the same destination path: their uploads would overwrite each other and only one could appear in the returned mapping. Files without a `destination_paths` entry are destined for their own basename, so two like-named files from different directories collide unless given distinct destinations.
- `OSError`: If a given file cannot be read.

### logger

```python
roboto.storage.file_service.logger
```

`from roboto.storage.file_service import logger`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/storage/file_service.py#L31-L31)
