Skip to main content

Files

The FilesResource class manages Files and Attachments associated with a Digital Product Passport. It allows you to upload documentation, images, or certificates directly to a DPP.

[!TIP] Integrity by Default: All files are automatically hashed upon upload. This cryptographic hash is stored to support future blockchain notarization, ensuring that the documents cannot be tampered with after the fact.


Methods

list

Retrieves a list of all files attached to a specific Digital Product Passport.

Signature

async list(dppId: string, options?: RequestOptions): Promise<Files[]>

Parameters

ParameterTypeDescription
dppIdstringThe unique identifier of the DPP.
optionsRequestOptions(Optional) Custom request configuration.

get

Retrieves the metadata for a single specific file.

Signature

async get(modelId: string, dppId: string, fileId: string, options?: RequestOptions): Promise<Files>

Parameters

ParameterTypeDescription
modelIdstringThe parent Model ID.
dppIdstringThe parent DPP ID.
fileIdstringThe unique identifier of the file.

create

Uploads a new file and associates it with a DPP. The SDK automatically reads the file's buffer to generate a cryptographic hash.

Signature

async create(modelId: string, dppId: string, data: CreateFile, options?: RequestOptions): Promise<Files>

Example (Deno / Browser)

const fileContent = await Deno.readFile("./manual.pdf");
const blob = new Blob([fileContent], { type: "application/pdf" });
const file = new File([blob], "manual.pdf");

const uploadedFile = await sdk.files.create("model_123", "dpp_456", {
name: "User Manual",
description: "Official product documentation",
file: file
});

Parameters

ParameterTypeDescription
modelIdstringThe parent Model ID.
dppIdstringThe parent DPP ID.
dataCreateFileObject containing file metadata (name, description) and the file (Blob/File).

update

Updates an existing file's metadata or replaces the file content itself. If a new file is provided, a new hash is generated.

Signature

async update(modelId: string, dppId: string, fileId: string, data: UpdateFile, options?: RequestOptions): Promise<Files>

Parameters

ParameterTypeDescription
modelIdstringThe parent Model ID.
dppIdstringThe parent DPP ID.
fileIdstringThe unique identifier of the file to update.
dataUpdateFileUpdated metadata or new file content.

delete

Deletes a file and removes its association from the DPP.

Signature

async delete(modelId: string, dppId: string, fileId: string, options?: RequestOptions): Promise<void>

[!WARNING] If a file upload fails or the server returns an error, an SDKError (HTTP 500) will be thrown containing the specific reason provided by the API.