HfHub.Commit.LfsUpload (HfHub v0.3.1)

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)
  • :lfs_upload_timeout - Socket receive timeout for direct LFS PUT/POST requests in milliseconds (default: 30 minutes)
  • :lfs_task_timeout - Task timeout per LFS object in milliseconds (default: :lfs_upload_timeout + 60_000)

Returns

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