Download

async AsyncCogniteClient.data_modeling.files.download(
directory: Path,
node_ids: NodeId | tuple[str, str] | Sequence[NodeId | tuple[str, str]],
keep_directory_structure: bool = False,
resolve_duplicate_file_names: bool = False,
) None

Download files by instance ID.

Streams all files to disk one chunk at a time. By default, chunk size is dynamic to maximize throughput; set global_config.file_download_chunk_size (bytes) to enforce a fixed size.

Parameters:
  • directory (Path) – Directory to download the file(s) to.

  • node_ids (NodeId | tuple[str, str] | Sequence[NodeId | tuple[str, str]]) – Instance ID or list of instance IDs.

  • keep_directory_structure (bool) – Whether to keep the directory hierarchy from CDF, creating subdirectories as needed.

  • resolve_duplicate_file_names (bool) – Whether to resolve duplicate file names by appending a number.

Examples

Download files by instance ID into directory ‘my_directory’:

>>> from pathlib import Path
>>> from cognite.client import CogniteClient
>>> from cognite.client.data_classes.data_modeling import NodeId
>>> client = CogniteClient()
>>> client.data_modeling.files.download(
...     directory=Path("my_directory"),
...     node_ids=[NodeId("my-space", "file-1"), NodeId("my-space", "file-2")],
... )