---
title: Using the object-storage
---

The Python SDK can be used to interface with Infrahub's [object-storage]($(base_url)artifact-file-storage/overview).

## Storing string objects to the object-storage

We can use the SDK to store string objects into the object-storage.

```python
import json

from infrahub_sdk import InfrahubClientSync


client = InfrahubClientSync()

data = {
    "key": "value",
    "list": [
        "item1",
        "item2",
        "item3",
    ]
}

response = client.object_store.upload(content=json.dumps(data))
print(response)
```

## Retrieving objects from the object-storage

Retrieving objects from the object-storage can be done using the object's identifier. In this step we will be using the identifier that we got as a response to the previous step.

```python
import json

from infrahub_sdk import InfrahubClientSync


client = InfrahubClientSync()
identifier = "17d19a20-70f6-3e44-3341-c5124065cda9"

response = client.object_store.get(identifier="17d19a20-70f6-3e44-3341-c5124065cda9")
print(json.loads(response))
```

## Storing a file to the object-storage

You can store text files in the object-storage. We have to read the contents of the file into a string object, which we can then store in the object-storage.

```python
import json
from pathlib import Path

from infrahub_sdk import InfrahubClientSync

data = {
    "key": "value",
    "list": [
        "item1",
        "item2",
        "item3",
    ]
}

json_file = Path("/tmp/file.json")
json_file.write_text(json.dumps(data))

client = InfrahubClientSync()
identifier = "17d19a20-70f6-3e44-3341-c5124065cda9"

response = client.object_store.upload(content=json_file.read_text())
print(response)
```
