Works with both data modeling and asset-centric projects.
See Files in data modeling for the full DM workflow.
| Your project type | How to identify files |
|---|---|
| Data modeling | Use instanceId — an object with space and externalId |
| Asset-centric (legacy) | Use externalId (string) or id (integer) |
File content vs file metadata
It’s important to understand the distinction between file content (the actual file data) and file metadata (information about the file):-
File content operations (covered on this page): Upload and download the actual file data using
uploadlink,downloadlink, and multipart upload endpoints. These work with both DM and asset-centric projects. -
File metadata operations: Create, update, search, and manage file metadata. The approach differs by project type:
- Data modeling: Use the Instances API to create and manage file nodes
- Asset-centric: Use the File metadata API to manage file metadata
Creating files
Before uploading file content, you must first create the file object:Data modeling projects
Create file nodes as instances in your data model using the Instances API. The file node must reference a view that includes theCogniteFile type from the core data model.
See Files in data modeling for detailed instructions.
Asset-centric projects
Create file metadata using the File metadata API. This returns a fileid or externalId that you can use for upload operations.
Uploading files
CDF supports two upload methods:- Single-part upload: For files up to 5 GB
- Multi-part upload: For files larger than 5 GB, uploaded in chunks
Single-part upload workflow
Get an upload URL
Request an upload URL from CDF, identifying the file using The response includes a temporary
instanceId (DM) or externalId/id (asset-centric).- Data modeling (instanceId)
- Asset-centric (externalId)
- Asset-centric (id)
uploadUrl:Multi-part upload workflow
For files larger than 5 GB, use multi-part upload to upload the file in chunks.Initialize multi-part upload
- Data modeling (instanceId)
- Asset-centric (externalId)
uploadId that you’ll use for subsequent steps.Downloading files
To download a file, request a temporary download URL and then retrieve the file content.Get a download URL
- Data modeling (instanceId)
- Asset-centric (externalId)
- Asset-centric (id)
downloadUrl:File icons
You can retrieve an icon or thumbnail for a file using the file icon endpoint. This works with both identification methods:- Data modeling (instanceId)
- Asset-centric (id)