# Interface: CommitEditFile

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

When `originalContent` is a XetBlob (as returned by [downloadFile](../modules#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[[edits.defined-in]]

[packages/hub/src/lib/commit.ts:84](https://github.com/huggingface/huggingface.js/blob/main/packages/hub/src/lib/commit.ts#L84)

___

### 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[[mode.defined-in]]

[packages/hub/src/lib/commit.ts:108](https://github.com/huggingface/huggingface.js/blob/main/packages/hub/src/lib/commit.ts#L108)

___

### operation

• **operation**: ``"edit"``

#### Defined in[[operation.defined-in]]

[packages/hub/src/lib/commit.ts:80](https://github.com/huggingface/huggingface.js/blob/main/packages/hub/src/lib/commit.ts#L80)

___

### originalContent

• **originalContent**: `Blob`

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

#### Defined in[[originalcontent.defined-in]]

[packages/hub/src/lib/commit.ts:83](https://github.com/huggingface/huggingface.js/blob/main/packages/hub/src/lib/commit.ts#L83)

___

### path

• **path**: `string`

#### Defined in[[path.defined-in]]

[packages/hub/src/lib/commit.ts:81](https://github.com/huggingface/huggingface.js/blob/main/packages/hub/src/lib/commit.ts#L81)

