Upload

async AsyncCogniteClient.data_modeling.files.upload(
path: Path,
node: NodeApply,
) None

Create a file node and upload content in one step.

The node is created (or updated) via instances.apply, then the file content is uploaded.

Parameters:
  • path (Path) – Path to the file to upload.

  • node (NodeApply) – The file node to apply before uploading.

Examples

Create a file node and upload content:

>>> from cognite.client import CogniteClient
>>> from cognite.client.data_classes.data_modeling.cdm.v1 import CogniteFileApply
>>> client = CogniteClient()
>>> file_name = "Quarterly-Report.pdf"
>>> client.data_modeling.files.upload(
...     Path(file_name),
...     CogniteFileApply(
...         space="my-space",
...         external_id="my-file",
...         name=file_name,
...         mime_type="application/pdf",
...     ),
... )