Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chunk upload #13

Open
Tracked by #11
jonesbusy opened this issue Oct 4, 2024 · 3 comments
Open
Tracked by #11

Chunk upload #13

jonesbusy opened this issue Oct 4, 2024 · 3 comments
Labels
enhancement New feature or request
Milestone

Comments

@jonesbusy
Copy link
Collaborator

Right now only POST and POST/PUT are implemented

Support for chunks upload

https://github.com/opencontainers/distribution-spec/blob/main/spec.md#pushing-a-blob-in-chunks

@jonesbusy jonesbusy mentioned this issue Oct 4, 2024
29 tasks
@jonesbusy jonesbusy added the enhancement New feature or request label Oct 4, 2024
@jonesbusy jonesbusy added this to the 1.0.0 milestone Oct 4, 2024
@jonesbusy
Copy link
Collaborator Author

Righ now using monolitic approach

    public Layer pushBlobStream(ContainerRef containerRef, InputStream input, long size) {
        try {
            // TODO: Replace by chunk upload
            Path tempFile = Files.createTempFile("oras", "layer");
            Files.copy(input, tempFile, StandardCopyOption.REPLACE_EXISTING);
            return pushBlob(containerRef, tempFile);
        } catch (IOException e) {
            throw new OrasException("Failed to push blob", e);
        }
    }

Stream need to be send by chunks

@vaidikcode
Copy link
Contributor

vaidikcode commented Feb 28, 2025

Hi @jonesbusy,

I wanted to follow up to see if you are currently working on the pushBlobStream method. I understand there were issues with its initial implementation. If you are not addressing this, I would be happy to create a pull request. I've reviewed the OCI Distribution Specification for uploading in chunks and wanted to confirm if I have understood it correctly

The pushBlobStream method in the Registry class implements chunked blob uploads following the OCI Distribution Specification's three-phase approach. First, it attempts to optimize by reading a portion of the stream to calculate a digest and check if the blob already exists in the registry. If not, it begins the upload process by (1) initializing an upload session with an empty POST request, (2) uploading data chunks via PATCH requests with proper Content-Range headers - starting with any data already read and continuing with remaining content while continuously updating the digest calculation, and finally (3) completing the upload with a PUT request containing the final digest.

Can you tell me if this is the correct approach for implementing chunk uploads?

Thanks

@jonesbusy
Copy link
Collaborator Author

Hi,

I'm not planning to work on it.

The process is decribed there https://github.com/opencontainers/distribution-spec/blob/main/spec.md#pushing-a-blob-in-chunks

Implement an integration test againts the zod container would confirm it works is expected.

The old pushStream implementation was badly implemented because integration test were running on a registry nor conformant to OCI 1.1. I guess it was working by chance.

Perhaps this method should be rename on pushChunks to match spec

I suggest to also take a look at the go implementation if you have doubts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants