Skip to content

Conversation

coyotte508
Copy link
Member

@coyotte508 coyotte508 commented Sep 2, 2025

Fix #1705

// Edit a file by adding prefix & suffix
await commit({
  repo,
  accessToken: "hf_...",
  operations: [{
    type: "edit",
    originalContent: originalFile,
    edits: [{
      start: 0,
      end: 0,
      content: new Blob(["prefix"])
    }, {
      start: originalFile.length,
      end: originalFile.length,
      content: new Blob(["suffix"])
    }]
  }]
})
// Edit first kB of file
await commit({
  repo,
  accessToken: "hf_...",
  operations: [{
    type: "edit",
    originalContent: originalFile,
    edits: [{
      start: 0,
      end: 1000,
      content: new Blob(["blablabla"])
    }]
  }]
})

cc @mishig25 @assafvayner @jsulz

also

  • fallback to LFS for non-xet repos (even if useXet is true)
  • remove invalid Accepts header

How it works under the hood

  • we load dedup info for first chunk of original file content if it's changed
  • we upload the blob as normal

Todo

currently blob is being processed twice, once for sha256 and once for hashing. The file should be processed only once (maybe after #1704 - using workers for different processes)

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@coyotte508 coyotte508 marked this pull request as ready for review September 2, 2025 14:08
@coyotte508 coyotte508 merged commit bd3c428 into main Sep 2, 2025
4 of 6 checks passed
@coyotte508 coyotte508 deleted the edit-file-chunk branch September 2, 2025 15:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

xet upload: allow changing only the beginning of the file
2 participants