HfHub.Commit.LfsUpload (HfHub v0.2.0)

Copy Markdown View Source

Git LFS upload protocol implementation.

Handles uploading large files (>= 10MB) using the Git LFS batch API. Supports both single-part and multipart uploads based on server response.

Summary

Functions

Requests upload instructions from the LFS batch endpoint.

Uploads multiple LFS files in batch.

Functions

request_batch_info(repo_id, upload_infos, token, opts \\ [])

@spec request_batch_info(
  String.t(),
  [HfHub.LFS.UploadInfo.t()],
  String.t(),
  keyword()
) ::
  {:ok, map()} | {:error, term()}

Requests upload instructions from the LFS batch endpoint.

Sends file info (OID and size) to the server and receives upload URLs and headers for each file.

upload_batch(repo_id, operations, token, opts \\ [])

@spec upload_batch(
  String.t(),
  [HfHub.Commit.Operation.Add.t()],
  String.t(),
  keyword()
) ::
  {:ok, [HfHub.Commit.Operation.Add.t()]} | {:error, term()}

Uploads multiple LFS files in batch.

Requests batch upload info from the server, uploads each file that needs uploading, and verifies uploads if required.

Options

  • :repo_type - Repository type: :model, :dataset, :space (default: :model)
  • :max_workers - Maximum concurrent uploads (default: 4)

Returns

Returns {:ok, operations} where operations have is_uploaded: true, or {:error, reason} on failure.