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
| Parameter | Type | Description |
|---|---|---|
dppId | string | The unique identifier of the DPP. |
options | RequestOptions | (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
| Parameter | Type | Description |
|---|---|---|
modelId | string | The parent Model ID. |
dppId | string | The parent DPP ID. |
fileId | string | The 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
| Parameter | Type | Description |
|---|---|---|
modelId | string | The parent Model ID. |
dppId | string | The parent DPP ID. |
data | CreateFile | Object 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
| Parameter | Type | Description |
|---|---|---|
modelId | string | The parent Model ID. |
dppId | string | The parent DPP ID. |
fileId | string | The unique identifier of the file to update. |
data | UpdateFile | Updated 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.