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

Adding new overload with length for BlobAsyncClient.upload() #30672

Merged
merged 10 commits into from
Sep 23, 2022

Conversation

ibrahimrabab
Copy link
Contributor

@ibrahimrabab ibrahimrabab commented Aug 26, 2022

resolves #6090

Instead of adding a new overload, we add a sample users can refer to in order to use upload method for a ByteBuffer with a known size.

@ghost ghost added the Storage Storage Service (Queues, Blobs, Files) label Aug 26, 2022
@alzimmermsft
Copy link
Member

I wonder if a better approach to this would be leveraging the fact that BinaryData created with a Flux<ByteBuffer> can pass the length: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/core/azure-core/src/main/java/com/azure/core/util/BinaryData.java#L393

This would hook into the BinaryData-based overload for upload and would require a few minor changes to how that BinaryData is consumed, for instance inspecting its length here: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/options/BlobParallelUploadOptions.java#L104

@azure-sdk
Copy link
Collaborator

API change check

API changes are not detected in this pull request.

// Since we already know the size of our buffered bytes, we can pass the ByteBuffer and length to the BinaryData.
// This will internally convert the BinaryData to a Flux<ByteBuffer>, but with known length we can optimize the
// upload speed.
BinaryData binaryData = BinaryData.fromFlux(sourceData, length).block();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two minor nits:

  • This returns a reactive response and can be reactively chained
  • There is two Flux length APIs in BinaryData, the one being used here will buffer the stream whereas the overload will allow this to be configured. We should call that out here

@ibrahimrabab ibrahimrabab requested review from alzimmermsft and removed request for rickle-msft and kasobol-msft September 22, 2022 22:14
@ibrahimrabab ibrahimrabab merged commit a094170 into Azure:main Sep 23, 2022
@ibrahimrabab ibrahimrabab deleted the blobClientUploadWLength branch September 23, 2022 17:37
fangjian0423 pushed a commit to fangjian0423/azure-sdk-for-java that referenced this pull request Sep 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Storage Storage Service (Queues, Blobs, Files)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Storage] Add API BlobAsyncClient.upload(Flux<ByteBuffer>, ParallelTransferOptions, length)
3 participants