> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/aistore/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.nvidia.com/aistore/_mcp/server.

# aistore.sdk.obj.object_writer

## Module Contents

### Classes

| Name                                                          | Description                                                 |
| ------------------------------------------------------------- | ----------------------------------------------------------- |
| [`ObjectWriter`](#aistore-sdk-obj-object_writer-ObjectWriter) | Provide a way to write an object's contents and attributes. |

### API

```python
class aistore.sdk.obj.object_writer.ObjectWriter(
    client: aistore.sdk.request_client.RequestClient,
    object_path: str,
    query_params: typing.Dict[str, str]
)
```

Provide a way to write an object's contents and attributes.

```python
aistore.sdk.obj.object_writer.ObjectWriter._put_data(
    data
) -> requests.Response
```

```python
aistore.sdk.obj.object_writer.ObjectWriter.append_content(
    content: bytes,
    handle: str = '',
    flush: bool = False
) -> str
```

Append bytes as an object to a bucket in AIS storage.

**Parameters:**

Bytes to append to the object.

Handle string to use for subsequent appends or flush (empty for the first append).

Whether to flush and finalize the append operation, making the object accessible.

**Returns:** `str`

Handle string to pass for subsequent appends or flush.

**Raises:**

* `requests.RequestException`: "There was an ambiguous exception that occurred while handling..."
* `requests.ConnectionError`: Connection error
* `requests.ConnectionTimeout`: Timed out connecting to AIStore
* `requests.ReadTimeout`: Timed out waiting response from AIStore
* `requests.exceptions.HTTPError(404)`: The object does not exist

```python
aistore.sdk.obj.object_writer.ObjectWriter.as_file(
    mode: str = 'a'
) -> aistore.sdk.obj.obj_file.object_file.ObjectFileWriter
```

Return a file-like object for writing object data.

**Parameters:**

Specifies the mode in which the file is opened (defaults to 'a').

Write mode. Opens the object for writing, truncating any existing content.
Writing starts from the beginning of the object.

Append mode. Opens the object for appending. Existing content is preserved,
and writing starts from the end of the object.

**Returns:** `ObjectFileWriter`

A file-like object for writing object data.

**Raises:**

* `ValueError`: Invalid mode provided.

```python
aistore.sdk.obj.object_writer.ObjectWriter.put_content(
    content: bytes
) -> requests.Response
```

Puts bytes as an object to a bucket in AIS storage.

**Parameters:**

Bytes to put as an object.

**Raises:**

* `requests.RequestException`: "There was an ambiguous exception that occurred while handling..."
* `requests.ConnectionError`: Connection error
* `requests.ConnectionTimeout`: Timed out connecting to AIStore
* `requests.ReadTimeout`: Timed out waiting response from AIStore

```python
aistore.sdk.obj.object_writer.ObjectWriter.put_file(
    path: str or Path
) -> requests.Response
```

Puts a local file as an object to a bucket in AIS storage.

**Parameters:**

Path to local file

**Raises:**

* `requests.RequestException`: "There was an ambiguous exception that occurred while handling..."
* `requests.ConnectionError`: Connection error
* `requests.ConnectionTimeout`: Timed out connecting to AIStore
* `requests.ReadTimeout`: Timed out waiting response from AIStore
* `ValueError`: The path provided is not a valid file

```python
aistore.sdk.obj.object_writer.ObjectWriter.set_custom_props(
    custom_metadata: typing.Dict[str, str],
    replace_existing: bool = False
) -> requests.Response
```

Set custom properties for the object.

**Parameters:**

Custom metadata key-value pairs.

Whether to replace existing metadata. Defaults to False.