public final class BlobClientBuilder extends Object
BlobClients
and BlobAsyncClients
, call buildClient
and buildAsyncClient
respectively to construct an instance of the desired client.
The following information must be provided on this builder:
.endpoint()
, including the container name and blob name, in the format of
https://{accountName}.blob.core.windows.net/{containerName}/{blobName}
.
.credential()
or .connectionString()
if the container is not publicly
accessible.
Constructor and Description |
---|
BlobClientBuilder()
Creates a builder instance that is able to configure and construct
BlobClients and BlobAsyncClients . |
Modifier and Type | Method and Description |
---|---|
BlobClientBuilder |
addPolicy(HttpPipelinePolicy pipelinePolicy)
Adds a pipeline policy to apply on each request sent.
|
BlobClientBuilder |
blobName(String blobName)
Sets the name of the blob.
|
BlobAsyncClient |
buildAsyncClient()
Creates a
BlobAsyncClient based on options set in the builder. |
BlobClient |
buildClient()
Creates a
BlobClient based on options set in the builder. |
BlobClientBuilder |
configuration(Configuration configuration)
Sets the configuration object used to retrieve environment configuration values during building of the client.
|
BlobClientBuilder |
connectionString(String connectionString)
Sets the connection string to connect to the service.
|
BlobClientBuilder |
containerName(String containerName)
Sets the name of the container that contains the blob.
|
BlobClientBuilder |
credential(StorageSharedKeyCredential credential)
Sets the
StorageSharedKeyCredential used to authorize requests sent to the service. |
BlobClientBuilder |
credential(TokenCredential credential)
Sets the
TokenCredential used to authorize requests sent to the service. |
BlobClientBuilder |
customerProvidedKey(CustomerProvidedKey customerProvidedKey)
Sets the
customer provided key that is used to encrypt blob contents on the server. |
BlobClientBuilder |
endpoint(String endpoint)
Sets the service endpoint, additionally parses it for information (SAS token, container name, blob name)
|
static HttpLogOptions |
getDefaultHttpLogOptions()
Gets the default Storage whitelist log headers and query parameters.
|
BlobClientBuilder |
httpClient(HttpClient httpClient)
Sets the
HttpClient to use for sending a receiving requests to and from the service. |
BlobClientBuilder |
httpLogOptions(HttpLogOptions logOptions)
Sets the
HttpLogOptions for service requests. |
BlobClientBuilder |
pipeline(HttpPipeline httpPipeline)
Sets the
HttpPipeline to use for the service client. |
BlobClientBuilder |
retryOptions(RequestRetryOptions retryOptions)
Sets the request retry options for all the requests made through the client.
|
BlobClientBuilder |
sasToken(String sasToken)
Sets the SAS token used to authorize requests sent to the service.
|
BlobClientBuilder |
serviceVersion(BlobServiceVersion version)
Sets the
BlobServiceVersion that is used when making API requests. |
BlobClientBuilder |
setAnonymousAccess()
Clears the credential used to authorize the request.
|
BlobClientBuilder |
snapshot(String snapshot)
Sets the snapshot identifier of the blob.
|
public BlobClientBuilder()
BlobClients
and BlobAsyncClients
.public BlobClient buildClient()
BlobClient
based on options set in the builder. BlobClients are used to perform generic blob
methods such as download
and get
properties
, use this when the blob type is unknown.
Code Samples
BlobClient
client = newBlobClientBuilder
() .connectionString(connectionString) .buildClient();
BlobClient
created from the configurations in this builder.NullPointerException
- If endpoint
or blobName
is null
.public BlobAsyncClient buildAsyncClient()
BlobAsyncClient
based on options set in the builder. BlobAsyncClients are used to perform
generic blob methods such as download
and BlobAsyncClientBase.getProperties()
, use this when the blob type is unknown.
Code Samples
BlobAsyncClient
client = newBlobClientBuilder
() .connectionString(connectionString) .buildAsyncClient();
BlobAsyncClient
created from the configurations in this builder.NullPointerException
- If endpoint
or blobName
is null
.public BlobClientBuilder customerProvidedKey(CustomerProvidedKey customerProvidedKey)
customer provided key
that is used to encrypt blob contents on the server.customerProvidedKey
- Customer provided key containing the encryption key information.public BlobClientBuilder credential(StorageSharedKeyCredential credential)
StorageSharedKeyCredential
used to authorize requests sent to the service.credential
- The credential to use for authenticating request.NullPointerException
- If credential
is null
.public BlobClientBuilder credential(TokenCredential credential)
TokenCredential
used to authorize requests sent to the service.credential
- The credential to use for authenticating request.NullPointerException
- If credential
is null
.public BlobClientBuilder sasToken(String sasToken)
sasToken
- The SAS token to use for authenticating requests.NullPointerException
- If sasToken
is null
.public BlobClientBuilder setAnonymousAccess()
This is for blobs that are publicly accessible.
public BlobClientBuilder connectionString(String connectionString)
connectionString
- Connection string of the storage account.IllegalArgumentException
- If connectionString
in invalid.public BlobClientBuilder endpoint(String endpoint)
If the endpoint is to a blob in the root container, this method will fail as it will interpret the blob name
as the container name. With only one path element, it is impossible to distinguish between a container name and
a blob in the root container, so it is assumed to be the container name as this is much more common. When working
with blobs in the root container, it is best to set the endpoint to the account url and specify the blob name
separately using the blobName
method.
endpoint
- URL of the serviceIllegalArgumentException
- If endpoint
is null
or is a malformed URL.public BlobClientBuilder containerName(String containerName)
containerName
- Name of the container. If the value null
or empty the root container, $root
, will be used.public BlobClientBuilder blobName(String blobName)
blobName
- Name of the blob.NullPointerException
- If blobName
is null
public BlobClientBuilder snapshot(String snapshot)
snapshot
- Snapshot identifier for the blob.public BlobClientBuilder httpClient(HttpClient httpClient)
HttpClient
to use for sending a receiving requests to and from the service.httpClient
- HttpClient to use for requests.public BlobClientBuilder addPolicy(HttpPipelinePolicy pipelinePolicy)
pipelinePolicy
- a pipeline policyNullPointerException
- If pipelinePolicy
is null
.public BlobClientBuilder httpLogOptions(HttpLogOptions logOptions)
HttpLogOptions
for service requests.logOptions
- The logging configuration to use when sending and receiving HTTP requests/responses.NullPointerException
- If logOptions
is null
.public static HttpLogOptions getDefaultHttpLogOptions()
public BlobClientBuilder configuration(Configuration configuration)
configuration
- Configuration store used to retrieve environment configurations.public BlobClientBuilder retryOptions(RequestRetryOptions retryOptions)
retryOptions
- The options used to configure retry behavior.NullPointerException
- If retryOptions
is null
.public BlobClientBuilder pipeline(HttpPipeline httpPipeline)
HttpPipeline
to use for the service client.
If pipeline
is set, all other settings are ignored, aside from endpoint
.httpPipeline
- HttpPipeline to use for sending service requests and receiving responses.public BlobClientBuilder serviceVersion(BlobServiceVersion version)
BlobServiceVersion
that is used when making API requests.
If a service version is not provided, the service version that will be used will be the latest known service version based on the version of the client library being used. If no service version is specified, updating to a newer version the client library will have the result of potentially moving to a newer service version.
version
- BlobServiceVersion
of the service to be used when making requests.Copyright © 2019 Microsoft Corporation. All rights reserved.