Skip to content

@ocfl/ocfl-fs

Stores and versions digital objects in an Oxford Common File Layout (OCFL) storage root on a local file system.

Start with createStorageRoot for a new storage root or openStorageRoot for an existing one. A StorageRoot opens, creates, lists and removes objects. An OcflObject gives each version’s files, and update adds a version from a Draft. A failure the library detects is an OcflError; test its code. File system errors, such as ENOSPC, pass through untouched, unless they leave a write needing recovery: then the error is RECOVERY_NEEDED, with the file system error as its cause.

import { openStorageRoot } from '@ocfl/ocfl-fs';
const root = await openStorageRoot('/srv/ocfl');
const object = await root.open('arcp://name,corpus/item/1');
await object.update({ message: 'Add transcript', user: { name: 'Alice' } }, async (draft) => {
await draft.write('transcript.txt', transcript);
});