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

# update_document_by_filename_with_file

> Update a document identified by filename with content from a file

<Tabs>
  <Tab title="Sync">
    ```python theme={null}
    def update_document_by_filename_with_file(
        filename: str,
        file: Union[str, bytes, BinaryIO, Path],
        new_filename: Optional[str] = None,
        metadata: Optional[Dict[str, Any]] = None,
        update_strategy: str = "add",
        use_colpali: Optional[bool] = None,
    ) -> Document
    ```
  </Tab>

  <Tab title="Async">
    ```python theme={null}
    async def update_document_by_filename_with_file(
        filename: str,
        file: Union[str, bytes, BinaryIO, Path],
        new_filename: Optional[str] = None,
        metadata: Optional[Dict[str, Any]] = None,
        update_strategy: str = "add",
        use_colpali: Optional[bool] = None,
    ) -> Document
    ```
  </Tab>
</Tabs>

## Parameters

* `filename` (str): Filename of the document to update
* `file` (Union\[str, bytes, BinaryIO, Path]): File to add (path string, bytes, file object, or Path)
* `new_filename` (str, optional): Optional new filename for the document (defaults to the filename of the file)
* `metadata` (Dict\[str, Any], optional): Additional metadata to update
* `update_strategy` (str, optional): Strategy for updating the document (currently only 'add' is supported). Defaults to 'add'.
* `use_colpali` (bool, optional): Whether to use multi-vector embedding. If not specified, defaults to True.

## Returns

* `Document`: Updated document metadata

## Examples

<Tabs>
  <Tab title="Sync">
    ```python theme={null}
    from morphik import Morphik

    db = Morphik()

    # Add content from a file to an existing document identified by filename
    updated_doc = db.update_document_by_filename_with_file(
        filename="report.pdf",
        file="path/to/update.pdf",
        metadata={"status": "updated"},
        update_strategy="add"
    )
    print(f"Document version: {updated_doc.system_metadata.get('version')}")
    ```
  </Tab>

  <Tab title="Async">
    ```python theme={null}
    from morphik import AsyncMorphik

    async with AsyncMorphik() as db:
        # Add content from a file to an existing document identified by filename
        updated_doc = await db.update_document_by_filename_with_file(
            filename="report.pdf",
            file="path/to/update.pdf",
            metadata={"status": "updated"},
            update_strategy="add"
        )
        print(f"Document version: {updated_doc.system_metadata.get('version')}")
    ```
  </Tab>
</Tabs>
