Skip to content

Stream blob uploads when digest/size are already known (no temp files) #508

@h2cone

Description

@h2cone

What would you like to be added?

Current OCI.pushBlob(ref, InputStream) spools to a temp file first (src/main/java/land/oras/OCI.java:109).

Add a streaming upload overload for the remote registry path, scoped to the "digest already known" case:

  • New API (Registry):
    Layer pushBlob(ContainerRef refWithDigest, long size, Supplier<InputStream> stream, Map<String,String> annotations)

Constraints / behavior:

  • refWithDigest.getDigest() is required; otherwise throw.
  • Implement upload as distribution-spec two-step: POST /blobs/uploads/ (no body) -> PUT <location>?digest=... (single streamed body).
  • Use BodyPublishers.ofInputStream(stream) so auth/redirect retries can reopen the stream (no temp files).

Copy usage:

  • Update src/main/java/land/oras/CopyUtils.java to call the new overload and pass known layer.getSize() + a stream supplier.

Non-goals:

  • Streaming when digest is not known (no "compute digest while uploading" in this change).
  • Changing existing pushBlob(Path|byte[]) behavior.

Why is this needed for ORAS?

  • Performance: avoid extra disk I/O and temp space for every copied blob.
  • Resource limits: works in constrained environments (CI runners, k8s, serverless).

Are you willing to submit PRs to contribute to this feature?

  • Yes, I am willing to implement it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions