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

[Storage] Add API BlobClient.upload(InputStream, length) #6089

Closed
mikeharder opened this issue Oct 30, 2019 · 1 comment · Fixed by #7835
Closed

[Storage] Add API BlobClient.upload(InputStream, length) #6089

mikeharder opened this issue Oct 30, 2019 · 1 comment · Fixed by #7835
Labels
Client This issue points to a problem in the data-plane of the library. design-discussion An area of design currently under discussion and open to team and community feedback. Storage Storage Service (Queues, Blobs, Files)

Comments

@mikeharder
Copy link
Member

mikeharder commented Oct 30, 2019

Track 1 provides the following API which automatically switches between single-put and stage-block upload based on the length:

CloudBlockBlob.upload(InputStream, long length)

For customers migrating from Track 1 to Track 2, I think we should provide a synchronous API as similar as possible. Currently in Track 2, there is no way to synchronously upload a stream of arbitrary size with good performance for small blobs. The only option is BlockBlobClient.getBlobOutputStream(), which is both more complicated to use and has poor performance for small blobs.

The implementation can simply call into the existing sync APIs:

public void BlobClient.upload(InputStream inputStream, long length) {
    BlockBlobClient blockBlobClient = this.getBlockBlobClient();
    if (length < singlePutMaximum) {
        return blockBlobClient.upload(inputStream, length);
    }
    else {
        BlobOutputStream blobOutputStream = blockBlobClient.getBlobOutputStream();
        inputStream.transferTo(blobOutputStream);
        blobOutputStream.close();
    }
}

Related: #5275

CC: @rickle-msft

@mikeharder mikeharder added the Client This issue points to a problem in the data-plane of the library. label Oct 30, 2019
@mikeharder mikeharder added design-discussion An area of design currently under discussion and open to team and community feedback. triage labels Oct 30, 2019
@mikeharder mikeharder added Storage Storage Service (Queues, Blobs, Files) design-discussion An area of design currently under discussion and open to team and community feedback. and removed design-discussion An area of design currently under discussion and open to team and community feedback. labels Oct 30, 2019
@rickle-msft
Copy link
Contributor

I agree that this would make migration easier and more intuitive. I'm ok with this addition.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Client This issue points to a problem in the data-plane of the library. design-discussion An area of design currently under discussion and open to team and community feedback. Storage Storage Service (Queues, Blobs, Files)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants