Huggingface.js documentation

Interface: CommitEditFile

Hugging Face's logo
Join the Hugging Face community

and get access to the augmented documentation experience

to get started

Interface: CommitEditFile

Edit an existing file by replacing byte ranges of its original content.

When originalContent is a XetBlob (as returned by downloadFile for xet-backed files), the unchanged parts of the file are neither downloaded nor re-chunked: the CAS server provides chunk-aligned edit windows and partial merkle data (GET /v2/file-chunk-hashes), so only the modified regions (plus their chunk-boundary neighborhood) are fetched, re-chunked and hashed.

  • For buckets (no sha256 involved), this means edits and appends require no download of the unchanged data at all.
  • For models/datasets/spaces, the unchanged data is still streamed once to compute the new file’s sha256 (required by the LFS protocol), instead of twice (sha256 + chunking).

With any other Blob as originalContent, the whole content is re-chunked locally and unchanged chunks are deduplicated against the remote (upload is skipped, but the content is read in full).

Properties

edits

• edits: { content: Blob ; end: number ; start: number }[]

Defined in

packages/hub/src/lib/commit.ts:84


mode

• Optional mode: number

POSIX file mode (st_mode), e.g. 0o755, optionally with file type bits 0o100000 (regular file) or 0o120000 (symlink, content is the link target).

Only supported for buckets, ignored otherwise. When omitted, the file has no mode on the Hub.

Defined in

packages/hub/src/lib/commit.ts:108


operation

• operation: "edit"

Defined in

packages/hub/src/lib/commit.ts:80


originalContent

• originalContent: Blob

Later, will be ContentSource. For now simpler to just handle blobs

Defined in

packages/hub/src/lib/commit.ts:83


path

• path: string

Defined in

packages/hub/src/lib/commit.ts:81

Update on GitHub