Skip to content

Commit c66b543

Browse files
authored
Update manifest-tasks.mdx
Add Node.js
1 parent fc7ecbe commit c66b543

File tree

1 file changed

+27
-5
lines changed

1 file changed

+27
-5
lines changed

docs/manifest/manifest-tasks.mdx

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,37 @@ except Exception as err:
7878
print(err)
7979
```
8080
81-
</TabItem>
82-
83-
<TabItem value="cpp" label="C++">
84-
This is how to read a manifest using C++.
8581
</TabItem>
8682
8783
<TabItem value="node" label="Node.js">
88-
This is how to read a manifest using Node.js.
84+
Use the `c2pa.read()` function to read a manifest; for example:
85+
86+
```ts
87+
import { createC2pa } from 'c2pa-node';
88+
import { readFile } from 'node:fs/promises';
89+
90+
const c2pa = createC2pa();
91+
92+
async function read(path, mimeType) {
93+
const buffer = await readFile(path);
94+
const result = await c2pa.read({ buffer, mimeType });
95+
96+
if (result) {
97+
const { active_manifest, manifests, validation_status } = result;
98+
console.log(active_manifest);
99+
} else {
100+
console.log('No claim found');
101+
}
102+
}
103+
104+
await read('my-c2pa-file.jpg', 'image/jpeg');
105+
```
89106
</TabItem>
107+
108+
<TabItem value="cpp" label="C++">
109+
This is how to read a manifest using C++.
110+
</TabItem>
111+
90112
</Tabs>
91113
92114
## Getting resources from a manifest

0 commit comments

Comments
 (0)