Upload a file content in string or bytes
- async AsyncCogniteClient.files.upload_content_bytes(
- content: str | bytes | BinaryIO,
- external_id: str | None = None,
- instance_id: NodeId | None = None,
Upload bytes or string (UTF-8 assumed).
Note that the maximum file size is 5GiB. In order to upload larger files use multipart_upload_content_session.
- Parameters:
content (str | bytes | BinaryIO) – The content to upload.
external_id (str | None) – The external ID provided by the client. Must be unique within the project.
instance_id (NodeId | None) – Instance ID of the file.
- Returns:
No description.
- Return type:
Examples
Finish a file creation by uploading the content using external_id:
>>> from cognite.client import CogniteClient, AsyncCogniteClient >>> client = CogniteClient() >>> # async_client = AsyncCogniteClient() # another option >>> res = client.files.upload_content_bytes(b"some content", external_id="my_file_xid")
…or by using instance_id:
>>> from cognite.client.data_classes.data_modeling import NodeId >>> res = client.files.upload_content_bytes( ... b"some content", instance_id=NodeId("my-space", "my_file_xid") ... )