Create file metadata
- async AsyncCogniteClient.files.create(
- file_metadata: FileMetadata | FileMetadataWrite,
- overwrite: bool = False,
Create file without uploading content.
- Parameters:
file_metadata (FileMetadata | FileMetadataWrite) – File metadata for the file to create.
overwrite (bool) – If ‘overwrite’ is set to true, and the POST body content specifies a ‘externalId’ field, fields for the file found for externalId can be overwritten. The default setting is false. If metadata is included in the request body, all of the original metadata will be overwritten. File-Asset mappings only change if explicitly stated in the assetIds field of the POST json body. Do not set assetIds in request body if you want to keep the current file-asset mappings.
- Returns:
Tuple containing the file metadata and upload url of the created file.
- Return type:
tuple[FileMetadata, str]
Examples
Create a file:
>>> from cognite.client import CogniteClient >>> from cognite.client.data_classes import FileMetadataWrite >>> client = CogniteClient() >>> # async_client = AsyncCogniteClient() # another option >>> file_metadata = FileMetadataWrite(name="MyFile") >>> res = client.files.create(file_metadata)