Skip to content

Commit

Permalink
Add Alan's SharedKeyCredential
Browse files Browse the repository at this point in the history
  • Loading branch information
jianghaolu committed Jun 11, 2019
1 parent bc8b084 commit 9ca1106
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import com.azure.storage.blob.implementation.AzureBlobStorageBuilder;
import com.azure.storage.blob.implementation.AzureBlobStorageImpl;
import com.azure.storage.common.credential.SharedKeyCredential;
import com.azure.storage.common.policy.SharedKeyCredentialPolicy;

import java.net.MalformedURLException;
import java.net.URL;
Expand Down Expand Up @@ -62,7 +63,12 @@ private AzureBlobStorageImpl buildImpl() {
policies.add(new UserAgentPolicy(BlobConfiguration.NAME, BlobConfiguration.VERSION));
policies.add(new RequestIdPolicy());
policies.add(new AddDatePolicy());
policies.add(credentials); // This needs to be a different credential type.
// TODO: Unify credentials
if (sharedKeyCredential != null) {
policies.add(new SharedKeyCredentialPolicy(sharedKeyCredential));
} else {
policies.add(credentials); // This needs to be a different credential type.
}

policies.add(retryPolicy);

Expand Down Expand Up @@ -109,7 +115,7 @@ public BlobServiceClientBuilder endpoint(String endpoint) {
* @param credentials authorization credentials
* @return the updated BlobServiceClientBuilder object
*/
public BlobServiceClientBuilder credentials(SharedKeyCredential credentials) {
public BlobServiceClientBuilder credentials(SharedKeyCredential sharedKeyCredential) {
this.sharedKeyCredential = sharedKeyCredential;
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.azure.storage.blob.models.BlockListType;
import com.azure.storage.blob.models.LeaseAccessConditions;
import com.azure.storage.blob.models.SourceModifiedAccessConditions;
import io.netty.buffer.Unpooled;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import reactor.netty.ByteBufFlux;
Expand Down Expand Up @@ -129,7 +130,7 @@ public BlockBlobUploadHeaders upload(InputStream data, long length, BlobHTTPHead
data.read(bufferedData);

Mono<BlockBlobUploadHeaders> response = blockBlobAsyncClient
.upload(ByteBufFlux.fromInbound(Flux.just(ByteBuffer.wrap(bufferedData))), length, headers, metadata, accessConditions, context);
.upload(Flux.just(Unpooled.wrappedBuffer(bufferedData)), length, headers, metadata, accessConditions, context);

return timeout == null?
response.block():
Expand Down

0 comments on commit 9ca1106

Please sign in to comment.