For large blobs, you can perform a chunked upload by initiating a session, pushing individual chunks, and then finalizing the session. This is useful for managing memory and handling large data transfers in stages.
- Call
begin_push_chunked_session to get a session location. - Call
push_chunk repeatedly with the session location and the data chunk. - Call
end_push_chunked_session with the final location and the total digest to complete the upload.
let location = c
.begin_push_chunked_session(&image)
.await
.expect("failed to begin push session");
let image_data = Bytes::from(b"iamawebassemblymodule".to_vec());
let (next_location, next_byte) = c
.push_chunk(&location, &image, image_data.clone(), 0)
.await
.expect("failed to push layer");
let layer_location = c
.end_push_chunked_session(&next_location, &image, &sha256_digest(&image_data))
.await
.expect("failed to end push session");