Huggingface.js documentation

接口:CommitEditFileParams

Hugging Face's logo
Join the Hugging Face community

and get access to the augmented documentation experience

to get started

接口:CommitEditFileParams

通过替换原始内容中的字节范围来编辑现有文件,而无需重新上传整个文件。

当 originalContent 来自基于 xet 的文件上的 downloadFile 时,未更改的部分既不会被下载,也不会被重新上传:仅传输已修改的字节范围(及其块边界附近区域)。当上传到存储桶时,此过程完全在远程执行——根本无需下载未更改的数据。

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]) }],
  },
});

属性

编辑

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

定义于

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


originalContent

• originalContent:Blob

该文件的当前内容,例如由 downloadFile 返回的内容

定义于

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


path

• path:string

定义于

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

Update on GitHub