Huggingface.js documentation

Interface: CommitEditFileParams

Hugging Face's logo
Join the Hugging Face community

and get access to the augmented documentation experience

to get started

Interface: CommitEditFileParams

Edit an existing file by replacing byte ranges of its original content, without re-uploading the whole file.

When originalContent comes from downloadFile on a xet-backed file, the unchanged parts are neither downloaded nor re-uploaded: only the modified byte ranges (and their chunk-boundary neighborhood) are transferred. This works fully remotely — without downloading the unchanged data at all — when uploading to a bucket.

Example

const original = await downloadFile({ repo: "buckets/me/repo", path: "model.gguf" });
await uploadFile({
  repo: "buckets/me/repo",
  file: {
    path: "model.gguf",
    originalContent: original,
    edits: [{ start: 0, end: 100, content: new Blob([patchedHeader]) }],
  },
});

Properties

edits

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

Defined in

packages/hub/src/lib/upload-file.ts:29


originalContent

originalContent: Blob

The file’s current content, eg as returned by downloadFile

Defined in

packages/hub/src/lib/upload-file.ts:28


path

path: string

Defined in

packages/hub/src/lib/upload-file.ts:26

Update on GitHub