Upload Bytes

async AsyncCogniteClient.data_modeling.files.upload_bytes(
content: str | bytes | BinaryIO,
node: NodeApply,
) None

Create a file node and upload in-memory content in one step.

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

Parameters:
  • content (str | bytes | BinaryIO) – The content to upload.

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

Examples

Create a file node and upload bytes:

>>> from cognite.client import CogniteClient
>>> from cognite.client.data_classes.data_modeling.cdm.v1 import CogniteFileApply
>>> client = CogniteClient()
>>> client.data_modeling.files.upload_bytes(
...     b"some important notes",
...     CogniteFileApply(
...         space="my-space",
...         external_id="my-file",
...         name="notes.txt",
...         mime_type="text/plain",
...     ),
... )