Works with both data modeling and asset-centric projects.
See Files in data modeling for the full DM workflow.
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
1
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:2
Upload the file content
Use the
uploadUrl to upload your file with a PUT request. The upload URL is valid for 30 minutes.After successful upload, the file content is available for download.
Multi-part upload workflow
For files larger than 5 GB, use multi-part upload to upload the file in chunks.1
Initialize multi-part upload
- Data modeling (instanceId)
- Asset-centric (externalId)
uploadId that you’ll use for subsequent steps.2
Get upload URLs for each part
3
Upload each part
Upload each part of your file to its corresponding URL using
PUT requests.4
Complete the multi-part upload
After uploading all parts, complete the upload:
CDF assembles the parts into a single file.
Downloading files
To download a file, request a temporary download URL and then retrieve the file content.1
Get a download URL
- Data modeling (instanceId)
- Asset-centric (externalId)
- Asset-centric (id)
downloadUrl:2
Download the file content
Use the
downloadUrl to retrieve the file with a GET request. The download URL is valid for 30 minutes.The response contains the file content with the appropriate Content-Type header.
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)