다음을 통해 공유


BlobClientBase Class

  • java.lang.Object
    • com.azure.storage.blob.specialized.BlobClientBase

public class BlobClientBase

This class provides a client that contains all operations that apply to any blob type.

This client offers the ability to download blobs. Note that uploading data is specific to each type of blob. Please refer to the BlockBlobClient, PageBlobClient, or AppendBlobClient for upload options.

Field Summary

Modifier and Type Field and Description
protected final String accountName

Storage account name that contains the blob.

protected final String blobName

Name of the blob.

protected final String containerName

Container name that contains the blob.

protected final BlobServiceVersion serviceVersion

Storage REST API version used in requests to the Storage service.

Constructor Summary

Modifier Constructor Description
protected BlobClientBase(BlobAsyncClientBase client)

Constructor used by SpecializedBlobClientBuilder.

protected BlobClientBase(BlobAsyncClientBase client, HttpPipeline pipeline, String url, BlobServiceVersion serviceVersion, String accountName, String containerName, String blobName, String snapshot, CpkInfo customerProvidedKey, EncryptionScope encryptionScope, String versionId)

Protected constructor for use by SpecializedBlobClientBuilder.

Method Summary

Modifier and Type Method and Description
void abortCopyFromUrl(String copyId)

Stops a pending copy that was previously started and leaves a destination blob with 0 length and metadata.

Response<Void> abortCopyFromUrlWithResponse(String copyId, String leaseId, Duration timeout, Context context)

Stops a pending copy that was previously started and leaves a destination blob with 0 length and metadata.

SyncPoller<BlobCopyInfo,Void> beginCopy(BlobBeginCopyOptions options)

Copies the data at the source URL to a blob.

SyncPoller<BlobCopyInfo,Void> beginCopy(String sourceUrl, Duration pollInterval)

Copies the data at the source URL to a blob.

SyncPoller<BlobCopyInfo,Void> beginCopy(String sourceUrl, Map<String,String> metadata, AccessTier tier, RehydratePriority priority, RequestConditions sourceModifiedRequestConditions, BlobRequestConditions destRequestConditions, Duration pollInterval)

Copies the data at the source URL to a blob.

String copyFromUrl(String copySource)

Copies the data at the source URL to a blob and waits for the copy to complete before returning a response.

Response<String> copyFromUrlWithResponse(BlobCopyFromUrlOptions options, Duration timeout, Context context)

Copies the data at the source URL to a blob and waits for the copy to complete before returning a response.

Response<String> copyFromUrlWithResponse(String copySource, Map<String,String> metadata, AccessTier tier, RequestConditions sourceModifiedRequestConditions, BlobRequestConditions destRequestConditions, Duration timeout, Context context)

Copies the data at the source URL to a blob and waits for the copy to complete before returning a response.

BlobClientBase createSnapshot()

Creates a read-only snapshot of the blob.

Response<BlobClientBase> createSnapshotWithResponse(Map<String,String> metadata, BlobRequestConditions requestConditions, Duration timeout, Context context)

Creates a read-only snapshot of the blob.

void delete()

Deletes the specified blob or snapshot.

boolean deleteIfExists()

Deletes the specified blob or snapshot if it exists.

Response<Boolean> deleteIfExistsWithResponse(DeleteSnapshotsOptionType deleteBlobSnapshotOptions, BlobRequestConditions requestConditions, Duration timeout, Context context)

Deletes the specified blob or snapshot if it exists.

void deleteImmutabilityPolicy()

Delete the immutability policy on a blob, blob snapshot or blob version.

Response<Void> deleteImmutabilityPolicyWithResponse(Duration timeout, Context context)

Delete the immutability policy on a blob, blob snapshot or blob version.

Response<Void> deleteWithResponse(DeleteSnapshotsOptionType deleteBlobSnapshotOptions, BlobRequestConditions requestConditions, Duration timeout, Context context)

Deletes the specified blob or snapshot.

void download(OutputStream stream)

Deprecated

Downloads the entire blob into an output stream.

BinaryData downloadContent()

Downloads the entire blob.

BlobDownloadContentResponse downloadContentWithResponse(DownloadRetryOptions options, BlobRequestConditions requestConditions, BlobRange range, boolean getRangeContentMd5, Duration timeout, Context context)

Downloads a range of bytes from a blob into an output stream.

BlobDownloadContentResponse downloadContentWithResponse(DownloadRetryOptions options, BlobRequestConditions requestConditions, Duration timeout, Context context)

Downloads a range of bytes from a blob into an output stream.

void downloadStream(OutputStream stream)

Downloads the entire blob into an output stream.

BlobDownloadResponse downloadStreamWithResponse(OutputStream stream, BlobRange range, DownloadRetryOptions options, BlobRequestConditions requestConditions, boolean getRangeContentMd5, Duration timeout, Context context)

Downloads a range of bytes from a blob into an output stream.

BlobProperties downloadToFile(String filePath)

Downloads the entire blob into a file specified by the path.

BlobProperties downloadToFile(String filePath, boolean overwrite)

Downloads the entire blob into a file specified by the path.

Response<BlobProperties> downloadToFileWithResponse(BlobDownloadToFileOptions options, Duration timeout, Context context)

Downloads the entire blob into a file specified by the path.

Response<BlobProperties> downloadToFileWithResponse(String filePath, BlobRange range, ParallelTransferOptions parallelTransferOptions, DownloadRetryOptions downloadRetryOptions, BlobRequestConditions requestConditions, boolean rangeGetContentMd5, Duration timeout, Context context)

Downloads the entire blob into a file specified by the path.

Response<BlobProperties> downloadToFileWithResponse(String filePath, BlobRange range, ParallelTransferOptions parallelTransferOptions, DownloadRetryOptions downloadRetryOptions, BlobRequestConditions requestConditions, boolean rangeGetContentMd5, Set<OpenOption> openOptions, Duration timeout, Context context)

Downloads the entire blob into a file specified by the path.

BlobDownloadResponse downloadWithResponse(OutputStream stream, BlobRange range, DownloadRetryOptions options, BlobRequestConditions requestConditions, boolean getRangeContentMd5, Duration timeout, Context context)

Deprecated

Downloads a range of bytes from a blob into an output stream.

Boolean exists()

Gets if the blob this client represents exists in the cloud.

Response<Boolean> existsWithResponse(Duration timeout, Context context)

Gets if the blob this client represents exists in the cloud.

String generateSas(BlobServiceSasSignatureValues blobServiceSasSignatureValues)

Generates a service SAS for the blob using the specified BlobServiceSasSignatureValues

String generateSas(BlobServiceSasSignatureValues blobServiceSasSignatureValues, Context context)

Generates a service SAS for the blob using the specified BlobServiceSasSignatureValues

String generateSas(BlobServiceSasSignatureValues blobServiceSasSignatureValues, Consumer<String> stringToSignHandler, Context context)

Generates a service SAS for the blob using the specified BlobServiceSasSignatureValues

String generateUserDelegationSas(BlobServiceSasSignatureValues blobServiceSasSignatureValues, UserDelegationKey userDelegationKey)

Generates a user delegation SAS for the blob using the specified BlobServiceSasSignatureValues.

String generateUserDelegationSas(BlobServiceSasSignatureValues blobServiceSasSignatureValues, UserDelegationKey userDelegationKey, String accountName, Context context)

Generates a user delegation SAS for the blob using the specified BlobServiceSasSignatureValues.

String generateUserDelegationSas(BlobServiceSasSignatureValues blobServiceSasSignatureValues, UserDelegationKey userDelegationKey, String accountName, Consumer<String> stringToSignHandler, Context context)

Generates a user delegation SAS for the blob using the specified BlobServiceSasSignatureValues.

StorageAccountInfo getAccountInfo()

Returns the sku name and account kind for the account.

Response<StorageAccountInfo> getAccountInfoWithResponse(Duration timeout, Context context)

Returns the sku name and account kind for the account.

String getAccountName()

Get associated account name.

String getAccountUrl()

Get the url of the storage account.

final String getBlobName()

Decodes and gets the blob name.

String getBlobUrl()

Gets the URL of the blob represented by this client.

BlobContainerClient getContainerClient()

Gets a client pointing to the parent container.

final String getContainerName()

Get the container name.

CpkInfo getCustomerProvidedKey()

Gets the CpkInfo used to encrypt this blob's content on the server.

BlobClientBase getCustomerProvidedKeyClient(CustomerProvidedKey customerProvidedKey)

Creates a new BlobClientBase with the specified customerProvidedKey.

String getEncryptionScope()

Gets the encryption scope used to encrypt this blob's content on the server.

BlobClientBase getEncryptionScopeClient(String encryptionScope)

Creates a new BlobClientBase with the specified encryptionScope.

HttpPipeline getHttpPipeline()

Gets the HttpPipeline powering this client.

BlobProperties getProperties()

Returns the blob's metadata and properties.

Response<BlobProperties> getPropertiesWithResponse(BlobRequestConditions requestConditions, Duration timeout, Context context)

Returns the blob's metadata and properties.

BlobServiceVersion getServiceVersion()

Gets the service version the client is using.

BlobClientBase getSnapshotClient(String snapshot)

Creates a new BlobClientBase linked to the snapshot of this blob resource.

String getSnapshotId()

Gets the snapshotId for a blob resource

Map<String,String> getTags()

Returns the blob's tags.

Response<Map<String,String>> getTagsWithResponse(BlobGetTagsOptions options, Duration timeout, Context context)

Returns the blob's tags.

BlobClientBase getVersionClient(String versionId)

Creates a new BlobClientBase linked to the version of this blob resource.

String getVersionId()

Gets the versionId for a blob resource

boolean isSnapshot()

Determines if a blob is a snapshot

BlobInputStream openInputStream()

Opens a blob input stream to download the blob.

BlobInputStream openInputStream(BlobRange range, BlobRequestConditions requestConditions)

Opens a blob input stream to download the specified range of the blob.

BlobInputStream openInputStream(BlobInputStreamOptions options)

Opens a blob input stream to download the specified range of the blob.

BlobInputStream openInputStream(BlobInputStreamOptions options, Context context)

Opens a blob input stream to download the specified range of the blob.

InputStream openQueryInputStream(String expression)

Opens a blob input stream to query the blob.

Response<InputStream> openQueryInputStreamWithResponse(BlobQueryOptions queryOptions)

Opens a blob input stream to query the blob.

BlobSeekableByteChannelReadResult openSeekableByteChannelRead(BlobSeekableByteChannelReadOptions options, Context context)

Opens a seekable byte channel in read-only mode to download the blob.

void query(OutputStream stream, String expression)

Queries an entire blob into an output stream.

BlobQueryResponse queryWithResponse(BlobQueryOptions queryOptions, Duration timeout, Context context)

Queries an entire blob into an output stream.

void setAccessTier(AccessTier tier)

Sets the tier on a blob.

Response<Void> setAccessTierWithResponse(AccessTier tier, RehydratePriority priority, String leaseId, Duration timeout, Context context)

Sets the tier on a blob.

Response<Void> setAccessTierWithResponse(BlobSetAccessTierOptions options, Duration timeout, Context context)

Sets the tier on a blob.

void setHttpHeaders(BlobHttpHeaders headers)

Changes a blob's HTTP header properties.

Response<Void> setHttpHeadersWithResponse(BlobHttpHeaders headers, BlobRequestConditions requestConditions, Duration timeout, Context context)

Changes a blob's HTTP header properties.

BlobImmutabilityPolicy setImmutabilityPolicy(BlobImmutabilityPolicy immutabilityPolicy)

Sets the immutability policy on a blob, blob snapshot or blob version.

Response<BlobImmutabilityPolicy> setImmutabilityPolicyWithResponse(BlobImmutabilityPolicy immutabilityPolicy, BlobRequestConditions requestConditions, Duration timeout, Context context)

Sets the immutability policy on a blob, blob snapshot or blob version.

BlobLegalHoldResult setLegalHold(boolean legalHold)

Sets a legal hold on the blob.

Response<BlobLegalHoldResult> setLegalHoldWithResponse(boolean legalHold, Duration timeout, Context context)

Sets a legal hold on the blob.

void setMetadata(Map<String,String> metadata)

Changes a blob's metadata.

Response<Void> setMetadataWithResponse(Map<String,String> metadata, BlobRequestConditions requestConditions, Duration timeout, Context context)

Changes a blob's metadata.

void setTags(Map<String,String> tags)

Sets user defined tags.

Response<Void> setTagsWithResponse(BlobSetTagsOptions options, Duration timeout, Context context)

Sets user defined tags.

void undelete()

Undelete restores the content and metadata of a soft-deleted blob and/or any associated soft-deleted snapshots.

Response<Void> undeleteWithResponse(Duration timeout, Context context)

Undelete restores the content and metadata of a soft-deleted blob and/or any associated soft-deleted snapshots.

Methods inherited from java.lang.Object

Field Details

accountName

protected final String accountName

Storage account name that contains the blob.

blobName

protected final String blobName

Name of the blob.

containerName

protected final String containerName

Container name that contains the blob.

serviceVersion

protected final BlobServiceVersion serviceVersion

Storage REST API version used in requests to the Storage service.

Constructor Details

BlobClientBase

protected BlobClientBase(BlobAsyncClientBase client)

Constructor used by SpecializedBlobClientBuilder.

Parameters:

client - the async blob client

BlobClientBase

protected BlobClientBase(BlobAsyncClientBase client, HttpPipeline pipeline, String url, BlobServiceVersion serviceVersion, String accountName, String containerName, String blobName, String snapshot, CpkInfo customerProvidedKey, EncryptionScope encryptionScope, String versionId)

Protected constructor for use by SpecializedBlobClientBuilder.

Parameters:

client - the async blob client
pipeline - The pipeline used to send and receive service requests.
url - The endpoint where to send service requests.
serviceVersion - The version of the service to receive requests.
accountName - The storage account name.
containerName - The container name.
blobName - The blob name.
snapshot - The snapshot identifier for the blob, pass null to interact with the blob directly.
customerProvidedKey - Customer provided key used during encryption of the blob's data on the server, pass null to allow the service to use its own encryption.
encryptionScope - Encryption scope used during encryption of the blob's data on the server, pass null to allow the service to use its own encryption.
versionId - The version identifier for the blob, pass null to interact with the latest blob version.

Method Details

abortCopyFromUrl

public void abortCopyFromUrl(String copyId)

Stops a pending copy that was previously started and leaves a destination blob with 0 length and metadata.

Code Samples

client.abortCopyFromUrl(copyId);
 System.out.println("Aborted copy completed.");

For more information, see the Azure Docs

Parameters:

copyId - The id of the copy operation to abort.

abortCopyFromUrlWithResponse

public Response abortCopyFromUrlWithResponse(String copyId, String leaseId, Duration timeout, Context context)

Stops a pending copy that was previously started and leaves a destination blob with 0 length and metadata.

Code Samples

System.out.printf("Aborted copy completed with status %d%n",
     client.abortCopyFromUrlWithResponse(copyId, leaseId, timeout,
         new Context(key2, value2)).getStatusCode());

For more information, see the Azure Docs

Parameters:

copyId - The id of the copy operation to abort.
leaseId - The lease ID the active lease on the blob must match.
timeout - An optional timeout value beyond which a RuntimeException will be raised.
context - Additional context that is passed through the Http pipeline during the service call.

Returns:

A response containing status code and HTTP headers.

beginCopy

public SyncPoller beginCopy(BlobBeginCopyOptions options)

Copies the data at the source URL to a blob.

This method triggers a long-running, asynchronous operations. The source may be another blob or an Azure File. If the source is in another account, the source must either be public or authenticated with a SAS token. If the source is in the same account, the Shared Key authorization on the destination will also be applied to the source. The source URL must be URL encoded.

Code Samples

Map<String, String> metadata = Collections.singletonMap("metadata", "value");
 Map<String, String> tags = Collections.singletonMap("tag", "value");
 BlobBeginCopySourceRequestConditions modifiedRequestConditions = new BlobBeginCopySourceRequestConditions()
     .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(7));
 BlobRequestConditions blobRequestConditions = new BlobRequestConditions().setLeaseId(leaseId);
 SyncPoller<BlobCopyInfo, Void> poller = client.beginCopy(new BlobBeginCopyOptions(url).setMetadata(metadata)
     .setTags(tags).setTier(AccessTier.HOT).setRehydratePriority(RehydratePriority.STANDARD)
     .setSourceRequestConditions(modifiedRequestConditions)
     .setDestinationRequestConditions(blobRequestConditions).setPollInterval(Duration.ofSeconds(2)));

 PollResponse<BlobCopyInfo> response = poller.waitUntil(LongRunningOperationStatus.SUCCESSFULLY_COMPLETED);
 System.out.printf("Copy identifier: %s%n", response.getValue().getCopyId());

For more information, see the Azure Docs

Parameters:

Returns:

A SyncPoller<T,U> to poll the progress of blob copy operation.

beginCopy

public SyncPoller beginCopy(String sourceUrl, Duration pollInterval)

Copies the data at the source URL to a blob.

This method triggers a long-running, asynchronous operations. The source may be another blob or an Azure File. If the source is in another account, the source must either be public or authenticated with a SAS token. If the source is in the same account, the Shared Key authorization on the destination will also be applied to the source. The source URL must be URL encoded.

Code Samples

final SyncPoller<BlobCopyInfo, Void> poller = client.beginCopy(url, Duration.ofSeconds(2));
 PollResponse<BlobCopyInfo> pollResponse = poller.poll();
 System.out.printf("Copy identifier: %s%n", pollResponse.getValue().getCopyId());

For more information, see the Azure Docs

Parameters:

sourceUrl - The source URL to copy from. URLs outside of Azure may only be copied to block blobs.
pollInterval - Duration between each poll for the copy status. If none is specified, a default of one second is used.

Returns:

A SyncPoller<T,U> to poll the progress of blob copy operation.

beginCopy

public SyncPoller beginCopy(String sourceUrl, Map metadata, AccessTier tier, RehydratePriority priority, RequestConditions sourceModifiedRequestConditions, BlobRequestConditions destRequestConditions, Duration pollInterval)

Copies the data at the source URL to a blob.

This method triggers a long-running, asynchronous operations. The source may be another blob or an Azure File. If the source is in another account, the source must either be public or authenticated with a SAS token. If the source is in the same account, the Shared Key authorization on the destination will also be applied to the source. The source URL must be URL encoded.

Code Samples

Map<String, String> metadata = Collections.singletonMap("metadata", "value");
 RequestConditions modifiedRequestConditions = new RequestConditions()
     .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(7));
 BlobRequestConditions blobRequestConditions = new BlobRequestConditions().setLeaseId(leaseId);
 SyncPoller<BlobCopyInfo, Void> poller = client.beginCopy(url, metadata, AccessTier.HOT,
     RehydratePriority.STANDARD, modifiedRequestConditions, blobRequestConditions, Duration.ofSeconds(2));

 PollResponse<BlobCopyInfo> response = poller.waitUntil(LongRunningOperationStatus.SUCCESSFULLY_COMPLETED);
 System.out.printf("Copy identifier: %s%n", response.getValue().getCopyId());

For more information, see the Azure Docs

Parameters:

sourceUrl - The source URL to copy from. URLs outside of Azure may only be copied to block blobs.
metadata - Metadata to associate with the destination blob. If there is leading or trailing whitespace in any metadata key or value, it must be removed or encoded.
tier - AccessTier for the destination blob.
priority - RehydratePriority for rehydrating the blob.
sourceModifiedRequestConditions - RequestConditions against the source. Standard HTTP Access conditions related to the modification of data. ETag and LastModifiedTime are used to construct conditions related to when the blob was changed relative to the given request. The request will fail if the specified condition is not satisfied.
destRequestConditions - BlobRequestConditions against the destination.
pollInterval - Duration between each poll for the copy status. If none is specified, a default of one second is used.

Returns:

A SyncPoller<T,U> to poll the progress of blob copy operation.

copyFromUrl

public String copyFromUrl(String copySource)

Copies the data at the source URL to a blob and waits for the copy to complete before returning a response.

The source must be a block blob no larger than 256MB. The source must also be either public or have a sas token attached. The URL must be URL encoded.

Code Samples

System.out.printf("Copy identifier: %s%n", client.copyFromUrl(url));

For more information, see the Azure Docs

Parameters:

copySource - The source URL to copy from.

Returns:

The copy ID for the long running operation.

copyFromUrlWithResponse

public Response copyFromUrlWithResponse(BlobCopyFromUrlOptions options, Duration timeout, Context context)

Copies the data at the source URL to a blob and waits for the copy to complete before returning a response.

The source must be a block blob no larger than 256MB. The source must also be either public or have a sas token attached. The URL must be URL encoded.

Code Samples

Map<String, String> metadata = Collections.singletonMap("metadata", "value");
 Map<String, String> tags = Collections.singletonMap("tag", "value");
 RequestConditions modifiedRequestConditions = new RequestConditions()
     .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(7));
 BlobRequestConditions blobRequestConditions = new BlobRequestConditions().setLeaseId(leaseId);

 System.out.printf("Copy identifier: %s%n",
     client.copyFromUrlWithResponse(new BlobCopyFromUrlOptions(url).setMetadata(metadata).setTags(tags)
         .setTier(AccessTier.HOT).setSourceRequestConditions(modifiedRequestConditions)
         .setDestinationRequestConditions(blobRequestConditions), timeout,
         new Context(key1, value1)).getValue());

For more information, see the Azure Docs

Parameters:

timeout - An optional timeout value beyond which a RuntimeException will be raised.
context - Additional context that is passed through the Http pipeline during the service call.

Returns:

The copy ID for the long running operation.

copyFromUrlWithResponse

public Response copyFromUrlWithResponse(String copySource, Map metadata, AccessTier tier, RequestConditions sourceModifiedRequestConditions, BlobRequestConditions destRequestConditions, Duration timeout, Context context)

Copies the data at the source URL to a blob and waits for the copy to complete before returning a response.

The source must be a block blob no larger than 256MB. The source must also be either public or have a sas token attached. The URL must be URL encoded.

Code Samples

Map<String, String> metadata = Collections.singletonMap("metadata", "value");
 RequestConditions modifiedRequestConditions = new RequestConditions()
     .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(7));
 BlobRequestConditions blobRequestConditions = new BlobRequestConditions().setLeaseId(leaseId);

 System.out.printf("Copy identifier: %s%n",
     client.copyFromUrlWithResponse(url, metadata, AccessTier.HOT, modifiedRequestConditions,
         blobRequestConditions, timeout,
         new Context(key1, value1)).getValue());

For more information, see the Azure Docs

Parameters:

copySource - The source URL to copy from. URLs outside of Azure may only be copied to block blobs.
metadata - Metadata to associate with the destination blob. If there is leading or trailing whitespace in any metadata key or value, it must be removed or encoded.
tier - AccessTier for the destination blob.
sourceModifiedRequestConditions - RequestConditions against the source. Standard HTTP Access conditions related to the modification of data. ETag and LastModifiedTime are used to construct conditions related to when the blob was changed relative to the given request. The request will fail if the specified condition is not satisfied.
destRequestConditions - BlobRequestConditions against the destination.
timeout - An optional timeout value beyond which a RuntimeException will be raised.
context - Additional context that is passed through the Http pipeline during the service call.

Returns:

The copy ID for the long running operation.

createSnapshot

public BlobClientBase createSnapshot()

Creates a read-only snapshot of the blob.

Code Samples

System.out.printf("Identifier for the snapshot is %s%n", client.createSnapshot().getSnapshotId());

For more information, see the Azure Docs

Returns:

A response containing a BlobClientBase which is used to interact with the created snapshot, use getSnapshotId() to get the identifier for the snapshot.

createSnapshotWithResponse

public Response createSnapshotWithResponse(Map metadata, BlobRequestConditions requestConditions, Duration timeout, Context context)

Creates a read-only snapshot of the blob.

Code Samples

Map<String, String> snapshotMetadata = Collections.singletonMap("metadata", "value");
 BlobRequestConditions requestConditions = new BlobRequestConditions().setLeaseId(leaseId);

 System.out.printf("Identifier for the snapshot is %s%n",
     client.createSnapshotWithResponse(snapshotMetadata, requestConditions, timeout,
         new Context(key1, value1)).getValue());

For more information, see the Azure Docs

Parameters:

metadata - Metadata to associate with the resource. If there is leading or trailing whitespace in any metadata key or value, it must be removed or encoded.
requestConditions - BlobRequestConditions
timeout - An optional timeout value beyond which a RuntimeException will be raised.
context - Additional context that is passed through the Http pipeline during the service call.

Returns:

A response containing a BlobClientBase which is used to interact with the created snapshot, use getSnapshotId() to get the identifier for the snapshot.

delete

public void delete()

Deletes the specified blob or snapshot. To delete a blob with its snapshots use deleteWithResponse(DeleteSnapshotsOptionType deleteBlobSnapshotOptions, BlobRequestConditions requestConditions, Duration timeout, Context context) and set DeleteSnapshotsOptionType to INCLUDE.

Code Samples

client.delete();
 System.out.println("Delete completed.");

For more information, see the Azure Docs

deleteIfExists

public boolean deleteIfExists()

Deletes the specified blob or snapshot if it exists. To delete a blob with its snapshots use deleteIfExistsWithResponse(DeleteSnapshotsOptionType deleteBlobSnapshotOptions, BlobRequestConditions requestConditions, Duration timeout, Context context) and set DeleteSnapshotsOptionType to INCLUDE.

Code Samples

boolean result = client.deleteIfExists();
 System.out.println("Delete completed: " + result);

For more information, see the Azure Docs

Returns:

true if delete succeeds, or false if blob does not exist.

deleteIfExistsWithResponse

public Response deleteIfExistsWithResponse(DeleteSnapshotsOptionType deleteBlobSnapshotOptions, BlobRequestConditions requestConditions, Duration timeout, Context context)

Deletes the specified blob or snapshot if it exists. To delete a blob with its snapshots use deleteIfExistsWithResponse(DeleteSnapshotsOptionType deleteBlobSnapshotOptions, BlobRequestConditions requestConditions, Duration timeout, Context context) and set DeleteSnapshotsOptionType to INCLUDE.

Code Samples

Response<Boolean> response = client.deleteIfExistsWithResponse(DeleteSnapshotsOptionType.INCLUDE, null, timeout,
     new Context(key1, value1));
 if (response.getStatusCode() == 404) {
     System.out.println("Does not exist.");
 } else {
     System.out.printf("Delete completed with status %d%n", response.getStatusCode());
 }

For more information, see the Azure Docs

Parameters:

deleteBlobSnapshotOptions - Specifies the behavior for deleting the snapshots on this blob. Include will delete the base blob and all snapshots. Only will delete only the snapshots. If a snapshot is being deleted, you must pass null.
requestConditions - BlobRequestConditions
timeout - An optional timeout value beyond which a RuntimeException will be raised.
context - Additional context that is passed through the Http pipeline during the service call.

Returns:

A response containing status code and HTTP headers. If Response<T>'s status code is 202, the base blob was successfully deleted. If status code is 404, the base blob does not exist.

deleteImmutabilityPolicy

public void deleteImmutabilityPolicy()

Delete the immutability policy on a blob, blob snapshot or blob version.

NOTE: Blob Versioning must be enabled on your storage account and the blob must be in a container with immutable storage with versioning enabled to call this API.

Code Samples

client.deleteImmutabilityPolicy();
 System.out.println("Completed immutability policy deletion.");

deleteImmutabilityPolicyWithResponse

public Response deleteImmutabilityPolicyWithResponse(Duration timeout, Context context)

Delete the immutability policy on a blob, blob snapshot or blob version.

NOTE: Blob Versioning must be enabled on your storage account and the blob must be in a container with immutable storage with versioning enabled to call this API.

Code Samples

System.out.println("Delete immutability policy completed with status: "
     + client.deleteImmutabilityPolicyWithResponse(timeout, new Context(key1, value1)).getStatusCode());

Parameters:

timeout - An optional timeout value beyond which a RuntimeException will be raised.
context - Additional context that is passed through the Http pipeline during the service call.

Returns:

A response containing the immutability policy.

deleteWithResponse

public Response deleteWithResponse(DeleteSnapshotsOptionType deleteBlobSnapshotOptions, BlobRequestConditions requestConditions, Duration timeout, Context context)

Deletes the specified blob or snapshot. To delete a blob with its snapshots use deleteWithResponse(DeleteSnapshotsOptionType deleteBlobSnapshotOptions, BlobRequestConditions requestConditions, Duration timeout, Context context) and set DeleteSnapshotsOptionType to INCLUDE.

Code Samples

System.out.printf("Delete completed with status %d%n",
     client.deleteWithResponse(DeleteSnapshotsOptionType.INCLUDE, null, timeout,
         new Context(key1, value1)).getStatusCode());

For more information, see the Azure Docs

Parameters:

deleteBlobSnapshotOptions - Specifies the behavior for deleting the snapshots on this blob. Include will delete the base blob and all snapshots. Only will delete only the snapshots. If a snapshot is being deleted, you must pass null.
requestConditions - BlobRequestConditions
timeout - An optional timeout value beyond which a RuntimeException will be raised.
context - Additional context that is passed through the Http pipeline during the service call.

Returns:

A response containing status code and HTTP headers.

download

@Deprecated
public void download(OutputStream stream)

Deprecated

Downloads the entire blob into an output stream. Uploading data must be done from the BlockBlobClient, PageBlobClient, or AppendBlobClient.

Code Samples

client.download(new ByteArrayOutputStream());
 System.out.println("Download completed.");

For more information, see the Azure Docs

This method will be deprecated in the future. Use downloadStream(OutputStream stream) instead.

Parameters:

stream - A non-null OutputStream instance where the downloaded data will be written.

downloadContent

public BinaryData downloadContent()

Downloads the entire blob. Uploading data must be done from the BlockBlobClient, PageBlobClient, or AppendBlobClient.

Code Samples

BinaryData data = client.downloadContent();
 System.out.printf("Downloaded %s", data.toString());

For more information, see the Azure Docs

This method supports downloads up to 2GB of data. Content will be buffered in memory. If the blob is larger, use downloadStream(OutputStream stream) to download larger blobs.

Returns:

The content of the blob.

downloadContentWithResponse

public BlobDownloadContentResponse downloadContentWithResponse(DownloadRetryOptions options, BlobRequestConditions requestConditions, BlobRange range, boolean getRangeContentMd5, Duration timeout, Context context)

Downloads a range of bytes from a blob into an output stream. Uploading data must be done from the BlockBlobClient, PageBlobClient, or AppendBlobClient.

Code Samples

DownloadRetryOptions options = new DownloadRetryOptions().setMaxRetryRequests(5);
 BlobRange range = new BlobRange(1024, 2048L);

 BlobDownloadContentResponse contentResponse = client.downloadContentWithResponse(options, null,
     range, false, timeout, new Context(key2, value2));
 BinaryData content = contentResponse.getValue();
 System.out.printf("Download completed with status %d and content%s%n",
     contentResponse.getStatusCode(), content.toString());

For more information, see the Azure Docs

This method supports downloads up to 2GB of data. Content will be buffered in memory. If the blob is larger, use #downloadStreamWithResponse(OutputStream, BlobRange, DownloadRetryOptions, BlobRequestConditions, boolean, Duration, Context) to download larger blobs.

Parameters:

requestConditions - BlobRequestConditions
range - BlobRange
getRangeContentMd5 - Whether the contentMD5 for the specified blob range should be returned.
timeout - An optional timeout value beyond which a RuntimeException will be raised.
context - Additional context that is passed through the Http pipeline during the service call.

Returns:

A response containing status code and HTTP headers.

downloadContentWithResponse

public BlobDownloadContentResponse downloadContentWithResponse(DownloadRetryOptions options, BlobRequestConditions requestConditions, Duration timeout, Context context)

Downloads a range of bytes from a blob into an output stream. Uploading data must be done from the BlockBlobClient, PageBlobClient, or AppendBlobClient.

Code Samples

DownloadRetryOptions options = new DownloadRetryOptions().setMaxRetryRequests(5);

 BlobDownloadContentResponse contentResponse = client.downloadContentWithResponse(options, null,
     timeout, new Context(key2, value2));
 BinaryData content = contentResponse.getValue();
 System.out.printf("Download completed with status %d and content%s%n",
     contentResponse.getStatusCode(), content.toString());

For more information, see the Azure Docs

This method supports downloads up to 2GB of data. Content will be buffered in memory. If the blob is larger, use #downloadStreamWithResponse(OutputStream, BlobRange, DownloadRetryOptions, BlobRequestConditions, boolean, Duration, Context) to download larger blobs.

Parameters:

requestConditions - BlobRequestConditions
timeout - An optional timeout value beyond which a RuntimeException will be raised.
context - Additional context that is passed through the Http pipeline during the service call.

Returns:

A response containing status code and HTTP headers.

downloadStream

public void downloadStream(OutputStream stream)

Downloads the entire blob into an output stream. Uploading data must be done from the BlockBlobClient, PageBlobClient, or AppendBlobClient.

Code Samples

client.downloadStream(new ByteArrayOutputStream());
 System.out.println("Download completed.");

For more information, see the Azure Docs

Parameters:

stream - A non-null OutputStream instance where the downloaded data will be written.

downloadStreamWithResponse

public BlobDownloadResponse downloadStreamWithResponse(OutputStream stream, BlobRange range, DownloadRetryOptions options, BlobRequestConditions requestConditions, boolean getRangeContentMd5, Duration timeout, Context context)

Downloads a range of bytes from a blob into an output stream. Uploading data must be done from the BlockBlobClient, PageBlobClient, or AppendBlobClient.

Code Samples

BlobRange range = new BlobRange(1024, 2048L);
 DownloadRetryOptions options = new DownloadRetryOptions().setMaxRetryRequests(5);

 System.out.printf("Download completed with status %d%n",
     client.downloadStreamWithResponse(new ByteArrayOutputStream(), range, options, null, false,
         timeout, new Context(key2, value2)).getStatusCode());

For more information, see the Azure Docs

Parameters:

stream - A non-null OutputStream instance where the downloaded data will be written.
range - BlobRange
requestConditions - BlobRequestConditions
getRangeContentMd5 - Whether the contentMD5 for the specified blob range should be returned.
timeout - An optional timeout value beyond which a RuntimeException will be raised.
context - Additional context that is passed through the Http pipeline during the service call.

Returns:

A response containing status code and HTTP headers.

downloadToFile

public BlobProperties downloadToFile(String filePath)

Downloads the entire blob into a file specified by the path.

The file will be created and must not exist, if the file already exists a FileAlreadyExistsException will be thrown.

Code Samples

client.downloadToFile(file);
 System.out.println("Completed download to file");

For more information, see the Azure Docs

Parameters:

filePath - A String representing the filePath where the downloaded data will be written.

Returns:

The blob properties and metadata.

downloadToFile

public BlobProperties downloadToFile(String filePath, boolean overwrite)

Downloads the entire blob into a file specified by the path.

If overwrite is set to false, the file will be created and must not exist, if the file already exists a FileAlreadyExistsException will be thrown.

Code Samples

boolean overwrite = false; // Default value
 client.downloadToFile(file, overwrite);
 System.out.println("Completed download to file");

For more information, see the Azure Docs

Parameters:

filePath - A String representing the filePath where the downloaded data will be written.
overwrite - Whether to overwrite the file, should the file exist.

Returns:

The blob properties and metadata.

downloadToFileWithResponse

public Response downloadToFileWithResponse(BlobDownloadToFileOptions options, Duration timeout, Context context)

Downloads the entire blob into a file specified by the path.

By default the file will be created and must not exist, if the file already exists a FileAlreadyExistsException will be thrown. To override this behavior, provide appropriate OpenOptions

Code Samples

client.downloadToFileWithResponse(new BlobDownloadToFileOptions(file)
     .setRange(new BlobRange(1024, 2018L))
     .setDownloadRetryOptions(new DownloadRetryOptions().setMaxRetryRequests(5))
     .setOpenOptions(new HashSet<>(Arrays.asList(StandardOpenOption.CREATE_NEW, StandardOpenOption.WRITE,
         StandardOpenOption.READ))), timeout, new Context(key2, value2));
 System.out.println("Completed download to file");

For more information, see the Azure Docs

Parameters:

timeout - An optional timeout value beyond which a RuntimeException will be raised.
context - Additional context that is passed through the Http pipeline during the service call.

Returns:

A response containing the blob properties and metadata.

downloadToFileWithResponse

public Response downloadToFileWithResponse(String filePath, BlobRange range, ParallelTransferOptions parallelTransferOptions, DownloadRetryOptions downloadRetryOptions, BlobRequestConditions requestConditions, boolean rangeGetContentMd5, Duration timeout, Context context)

Downloads the entire blob into a file specified by the path.

The file will be created and must not exist, if the file already exists a FileAlreadyExistsException will be thrown.

Code Samples

BlobRange range = new BlobRange(1024, 2048L);
 DownloadRetryOptions options = new DownloadRetryOptions().setMaxRetryRequests(5);

 client.downloadToFileWithResponse(file, range, new ParallelTransferOptions().setBlockSizeLong(4L * Constants.MB),
     options, null, false, timeout, new Context(key2, value2));
 System.out.println("Completed download to file");

For more information, see the Azure Docs

Parameters:

filePath - A String representing the filePath where the downloaded data will be written.
range - BlobRange
parallelTransferOptions - ParallelTransferOptions to use to download to file. Number of parallel transfers parameter is ignored.
downloadRetryOptions - DownloadRetryOptions
requestConditions - BlobRequestConditions
rangeGetContentMd5 - Whether the contentMD5 for the specified blob range should be returned.
timeout - An optional timeout value beyond which a RuntimeException will be raised.
context - Additional context that is passed through the Http pipeline during the service call.

Returns:

A response containing the blob properties and metadata.

downloadToFileWithResponse

public Response downloadToFileWithResponse(String filePath, BlobRange range, ParallelTransferOptions parallelTransferOptions, DownloadRetryOptions downloadRetryOptions, BlobRequestConditions requestConditions, boolean rangeGetContentMd5, Set openOptions, Duration timeout, Context context)

Downloads the entire blob into a file specified by the path.

By default the file will be created and must not exist, if the file already exists a FileAlreadyExistsException will be thrown. To override this behavior, provide appropriate OpenOptions

Code Samples

BlobRange blobRange = new BlobRange(1024, 2048L);
 DownloadRetryOptions downloadRetryOptions = new DownloadRetryOptions().setMaxRetryRequests(5);
 Set<OpenOption> openOptions = new HashSet<>(Arrays.asList(StandardOpenOption.CREATE_NEW,
     StandardOpenOption.WRITE, StandardOpenOption.READ)); // Default options

 client.downloadToFileWithResponse(file, blobRange, new ParallelTransferOptions().setBlockSizeLong(4L * Constants.MB),
     downloadRetryOptions, null, false, openOptions, timeout, new Context(key2, value2));
 System.out.println("Completed download to file");

For more information, see the Azure Docs

Parameters:

filePath - A String representing the filePath where the downloaded data will be written.
range - BlobRange
parallelTransferOptions - ParallelTransferOptions to use to download to file. Number of parallel transfers parameter is ignored.
downloadRetryOptions - DownloadRetryOptions
requestConditions - BlobRequestConditions
rangeGetContentMd5 - Whether the contentMD5 for the specified blob range should be returned.
openOptions - OpenOptions to use to configure how to open or create the file.
timeout - An optional timeout value beyond which a RuntimeException will be raised.
context - Additional context that is passed through the Http pipeline during the service call.

Returns:

A response containing the blob properties and metadata.

downloadWithResponse

@Deprecated
public BlobDownloadResponse downloadWithResponse(OutputStream stream, BlobRange range, DownloadRetryOptions options, BlobRequestConditions requestConditions, boolean getRangeContentMd5, Duration timeout, Context context)

Deprecated

Downloads a range of bytes from a blob into an output stream. Uploading data must be done from the BlockBlobClient, PageBlobClient, or AppendBlobClient.

Code Samples

BlobRange range = new BlobRange(1024, 2048L);
 DownloadRetryOptions options = new DownloadRetryOptions().setMaxRetryRequests(5);

 System.out.printf("Download completed with status %d%n",
     client.downloadWithResponse(new ByteArrayOutputStream(), range, options, null, false,
         timeout, new Context(key2, value2)).getStatusCode());

For more information, see the Azure Docs

This method will be deprecated in the future. Use #downloadStreamWithResponse(OutputStream, BlobRange, DownloadRetryOptions, BlobRequestConditions, boolean, Duration, Context) instead.

Parameters:

stream - A non-null OutputStream instance where the downloaded data will be written.
range - BlobRange
requestConditions - BlobRequestConditions
getRangeContentMd5 - Whether the contentMD5 for the specified blob range should be returned.
timeout - An optional timeout value beyond which a RuntimeException will be raised.
context - Additional context that is passed through the Http pipeline during the service call.

Returns:

A response containing status code and HTTP headers.

exists

public Boolean exists()

Gets if the blob this client represents exists in the cloud.

Code Samples

System.out.printf("Exists? %b%n", client.exists());

Returns:

true if the blob exists, false if it doesn't

existsWithResponse

public Response existsWithResponse(Duration timeout, Context context)

Gets if the blob this client represents exists in the cloud.

Code Samples

System.out.printf("Exists? %b%n", client.existsWithResponse(timeout, new Context(key2, value2)).getValue());

Parameters:

timeout - An optional timeout value beyond which a RuntimeException will be raised.
context - Additional context that is passed through the Http pipeline during the service call.

Returns:

true if the blob exists, false if it doesn't

generateSas

public String generateSas(BlobServiceSasSignatureValues blobServiceSasSignatureValues)

Generates a service SAS for the blob using the specified BlobServiceSasSignatureValues

Note : The client must be authenticated via StorageSharedKeyCredential

See BlobServiceSasSignatureValues for more information on how to construct a service SAS.

Code Samples

OffsetDateTime expiryTime = OffsetDateTime.now().plusDays(1);
 BlobSasPermission permission = new BlobSasPermission().setReadPermission(true);

 BlobServiceSasSignatureValues values = new BlobServiceSasSignatureValues(expiryTime, permission)
     .setStartTime(OffsetDateTime.now());

 client.generateSas(values); // Client must be authenticated via StorageSharedKeyCredential

Parameters:

blobServiceSasSignatureValues - BlobServiceSasSignatureValues

Returns:

A String representing the SAS query parameters.

generateSas

public String generateSas(BlobServiceSasSignatureValues blobServiceSasSignatureValues, Context context)

Generates a service SAS for the blob using the specified BlobServiceSasSignatureValues

Note : The client must be authenticated via StorageSharedKeyCredential

See BlobServiceSasSignatureValues for more information on how to construct a service SAS.

Code Samples

OffsetDateTime expiryTime = OffsetDateTime.now().plusDays(1);
 BlobSasPermission permission = new BlobSasPermission().setReadPermission(true);

 BlobServiceSasSignatureValues values = new BlobServiceSasSignatureValues(expiryTime, permission)
     .setStartTime(OffsetDateTime.now());

 // Client must be authenticated via StorageSharedKeyCredential
 client.generateSas(values, new Context(key1, value1));

Parameters:

blobServiceSasSignatureValues - BlobServiceSasSignatureValues
context - Additional context that is passed through the code when generating a SAS.

Returns:

A String representing the SAS query parameters.

generateSas

public String generateSas(BlobServiceSasSignatureValues blobServiceSasSignatureValues, Consumer stringToSignHandler, Context context)

Generates a service SAS for the blob using the specified BlobServiceSasSignatureValues

Note : The client must be authenticated via StorageSharedKeyCredential

See BlobServiceSasSignatureValues for more information on how to construct a service SAS.

Parameters:

blobServiceSasSignatureValues - BlobServiceSasSignatureValues
stringToSignHandler - For debugging purposes only. Returns the string to sign that was used to generate the signature.
context - Additional context that is passed through the code when generating a SAS.

Returns:

A String representing the SAS query parameters.

generateUserDelegationSas

public String generateUserDelegationSas(BlobServiceSasSignatureValues blobServiceSasSignatureValues, UserDelegationKey userDelegationKey)

Generates a user delegation SAS for the blob using the specified BlobServiceSasSignatureValues.

See BlobServiceSasSignatureValues for more information on how to construct a user delegation SAS.

Code Samples

OffsetDateTime myExpiryTime = OffsetDateTime.now().plusDays(1);
 BlobSasPermission myPermission = new BlobSasPermission().setReadPermission(true);

 BlobServiceSasSignatureValues myValues = new BlobServiceSasSignatureValues(expiryTime, permission)
     .setStartTime(OffsetDateTime.now());

 client.generateUserDelegationSas(values, userDelegationKey);

Parameters:

blobServiceSasSignatureValues - BlobServiceSasSignatureValues
userDelegationKey - A UserDelegationKey object used to sign the SAS values. See getUserDelegationKey(OffsetDateTime start, OffsetDateTime expiry) for more information on how to get a user delegation key.

Returns:

A String representing the SAS query parameters.

generateUserDelegationSas

public String generateUserDelegationSas(BlobServiceSasSignatureValues blobServiceSasSignatureValues, UserDelegationKey userDelegationKey, String accountName, Context context)

Generates a user delegation SAS for the blob using the specified BlobServiceSasSignatureValues.

See BlobServiceSasSignatureValues for more information on how to construct a user delegation SAS.

Code Samples

OffsetDateTime myExpiryTime = OffsetDateTime.now().plusDays(1);
 BlobSasPermission myPermission = new BlobSasPermission().setReadPermission(true);

 BlobServiceSasSignatureValues myValues = new BlobServiceSasSignatureValues(expiryTime, permission)
     .setStartTime(OffsetDateTime.now());

 client.generateUserDelegationSas(values, userDelegationKey, accountName, new Context(key1, value1));

Parameters:

blobServiceSasSignatureValues - BlobServiceSasSignatureValues
userDelegationKey - A UserDelegationKey object used to sign the SAS values. See getUserDelegationKey(OffsetDateTime start, OffsetDateTime expiry) for more information on how to get a user delegation key.
accountName - The account name.
context - Additional context that is passed through the code when generating a SAS.

Returns:

A String representing the SAS query parameters.

generateUserDelegationSas

public String generateUserDelegationSas(BlobServiceSasSignatureValues blobServiceSasSignatureValues, UserDelegationKey userDelegationKey, String accountName, Consumer stringToSignHandler, Context context)

Generates a user delegation SAS for the blob using the specified BlobServiceSasSignatureValues.

See BlobServiceSasSignatureValues for more information on how to construct a user delegation SAS.

Parameters:

blobServiceSasSignatureValues - BlobServiceSasSignatureValues
userDelegationKey - A UserDelegationKey object used to sign the SAS values. See getUserDelegationKey(OffsetDateTime start, OffsetDateTime expiry) for more information on how to get a user delegation key.
accountName - The account name.
stringToSignHandler - For debugging purposes only. Returns the string to sign that was used to generate the signature.
context - Additional context that is passed through the code when generating a SAS.

Returns:

A String representing the SAS query parameters.

getAccountInfo

public StorageAccountInfo getAccountInfo()

Returns the sku name and account kind for the account.

Code Samples

StorageAccountInfo accountInfo = client.getAccountInfo();
 System.out.printf("Account Kind: %s, SKU: %s%n", accountInfo.getAccountKind(), accountInfo.getSkuName());

For more information, see the Azure Docs

Returns:

The sku name and account kind.

getAccountInfoWithResponse

public Response getAccountInfoWithResponse(Duration timeout, Context context)

Returns the sku name and account kind for the account.

Code Samples

StorageAccountInfo accountInfo = client.getAccountInfoWithResponse(timeout, new Context(key1, value1)).getValue();
 System.out.printf("Account Kind: %s, SKU: %s%n", accountInfo.getAccountKind(), accountInfo.getSkuName());

For more information, see the Azure Docs

Parameters:

timeout - An optional timeout value beyond which a RuntimeException will be raised.
context - Additional context that is passed through the Http pipeline during the service call.

Returns:

The sku name and account kind.

getAccountName

public String getAccountName()

Get associated account name.

Returns:

account name associated with this storage resource.

getAccountUrl

public String getAccountUrl()

Get the url of the storage account.

Returns:

the URL of the storage account

getBlobName

public final String getBlobName()

Decodes and gets the blob name.

Code Samples

String blobName = client.getBlobName();
 System.out.println("The name of the blob is " + blobName);

Returns:

The decoded name of the blob.

getBlobUrl

public String getBlobUrl()

Gets the URL of the blob represented by this client.

Returns:

the URL.

getContainerClient

public BlobContainerClient getContainerClient()

Gets a client pointing to the parent container.

Code Samples

BlobContainerClient containerClient = client.getContainerClient();
 System.out.println("The name of the container is " + containerClient.getBlobContainerName());

Returns:

getContainerName

public final String getContainerName()

Get the container name.

Code Samples

String containerName = client.getContainerName();
 System.out.println("The name of the container is " + containerName);

Returns:

The name of the container.

getCustomerProvidedKey

public CpkInfo getCustomerProvidedKey()

Gets the CpkInfo used to encrypt this blob's content on the server.

Returns:

the customer provided key used for encryption.

getCustomerProvidedKeyClient

public BlobClientBase getCustomerProvidedKeyClient(CustomerProvidedKey customerProvidedKey)

Creates a new BlobClientBase with the specified customerProvidedKey.

Parameters:

customerProvidedKey - the CustomerProvidedKey for the blob, pass null to use no customer provided key.

Returns:

a BlobClientBase with the specified customerProvidedKey.

getEncryptionScope

public String getEncryptionScope()

Gets the encryption scope used to encrypt this blob's content on the server.

Returns:

the encryption scope used for encryption.

getEncryptionScopeClient

public BlobClientBase getEncryptionScopeClient(String encryptionScope)

Creates a new BlobClientBase with the specified encryptionScope.

Parameters:

encryptionScope - the encryption scope for the blob, pass null to use no encryption scope.

Returns:

a BlobClientBase with the specified encryptionScope.

getHttpPipeline

public HttpPipeline getHttpPipeline()

Gets the HttpPipeline powering this client.

Returns:

The pipeline.

getProperties

public BlobProperties getProperties()

Returns the blob's metadata and properties.

Code Samples

BlobProperties properties = client.getProperties();
 System.out.printf("Type: %s, Size: %d%n", properties.getBlobType(), properties.getBlobSize());

For more information, see the Azure Docs

Returns:

The blob properties and metadata.

getPropertiesWithResponse

public Response getPropertiesWithResponse(BlobRequestConditions requestConditions, Duration timeout, Context context)

Returns the blob's metadata and properties.

Code Samples

BlobRequestConditions requestConditions = new BlobRequestConditions().setLeaseId(leaseId);

 BlobProperties properties = client.getPropertiesWithResponse(requestConditions, timeout,
     new Context(key2, value2)).getValue();
 System.out.printf("Type: %s, Size: %d%n", properties.getBlobType(), properties.getBlobSize());

For more information, see the Azure Docs

Parameters:

requestConditions - BlobRequestConditions
timeout - An optional timeout value beyond which a RuntimeException will be raised.
context - Additional context that is passed through the Http pipeline during the service call.

Returns:

The blob properties and metadata.

getServiceVersion

public BlobServiceVersion getServiceVersion()

Gets the service version the client is using.

Returns:

the service version the client is using.

getSnapshotClient

public BlobClientBase getSnapshotClient(String snapshot)

Creates a new BlobClientBase linked to the snapshot of this blob resource.

Parameters:

snapshot - the identifier for a specific snapshot of this blob

Returns:

a BlobClientBase used to interact with the specific snapshot.

getSnapshotId

public String getSnapshotId()

Gets the snapshotId for a blob resource

Returns:

A string that represents the snapshotId of the snapshot blob

getTags

public Map getTags()

Returns the blob's tags.

Code Samples

Map<String, String> tags = client.getTags();
 System.out.printf("Number of tags: %d%n", tags.size());

For more information, see the Azure Docs

Returns:

The blob's tags.

getTagsWithResponse

public Response> getTagsWithResponse(BlobGetTagsOptions options, Duration timeout, Context context)

Returns the blob's tags.

Code Samples

Map<String, String> tags = client.getTagsWithResponse(new BlobGetTagsOptions(), timeout,
     new Context(key1, value1)).getValue();
 System.out.printf("Number of tags: %d%n", tags.size());

For more information, see the Azure Docs

Parameters:

options - BlobGetTagsOptions
timeout - An optional timeout value beyond which a RuntimeException will be raised.
context - Additional context that is passed through the Http pipeline during the service call.

Returns:

The blob's tags.

getVersionClient

public BlobClientBase getVersionClient(String versionId)

Creates a new BlobClientBase linked to the version of this blob resource.

Parameters:

versionId - the identifier for a specific version of this blob, pass null to interact with the latest blob version.

Returns:

a BlobClientBase used to interact with the specific version.

getVersionId

public String getVersionId()

Gets the versionId for a blob resource

Returns:

A string that represents the versionId of the snapshot blob

isSnapshot

public boolean isSnapshot()

Determines if a blob is a snapshot

Returns:

A boolean that indicates if a blob is a snapshot

openInputStream

public BlobInputStream openInputStream()

Opens a blob input stream to download the blob.

Returns:

An InputStream object that represents the stream to use for reading from the blob.

openInputStream

public BlobInputStream openInputStream(BlobRange range, BlobRequestConditions requestConditions)

Opens a blob input stream to download the specified range of the blob.

Parameters:

range - BlobRange
requestConditions - An BlobRequestConditions object that represents the access conditions for the blob.

Returns:

An InputStream object that represents the stream to use for reading from the blob.

openInputStream

public BlobInputStream openInputStream(BlobInputStreamOptions options)

Opens a blob input stream to download the specified range of the blob.

Parameters:

Returns:

An InputStream object that represents the stream to use for reading from the blob.

openInputStream

public BlobInputStream openInputStream(BlobInputStreamOptions options, Context context)

Opens a blob input stream to download the specified range of the blob.

Parameters:

context - Context

Returns:

An InputStream object that represents the stream to use for reading from the blob.

openQueryInputStream

public InputStream openQueryInputStream(String expression)

Opens a blob input stream to query the blob.

For more information, see the Azure Docs

Code Samples

String expression = "SELECT * from BlobStorage";
 InputStream inputStream = client.openQueryInputStream(expression);
 // Now you can read from the input stream like you would normally.

Parameters:

expression - The query expression.

Returns:

An InputStream object that represents the stream to use for reading the query response.

openQueryInputStreamWithResponse

public Response openQueryInputStreamWithResponse(BlobQueryOptions queryOptions)

Opens a blob input stream to query the blob.

For more information, see the Azure Docs

Code Samples

String expression = "SELECT * from BlobStorage";
 BlobQuerySerialization input = new BlobQueryDelimitedSerialization()
     .setColumnSeparator(',')
     .setEscapeChar('\n')
     .setRecordSeparator('\n')
     .setHeadersPresent(true)
     .setFieldQuote('"');
 BlobQuerySerialization output = new BlobQueryJsonSerialization()
     .setRecordSeparator('\n');
 BlobRequestConditions requestConditions = new BlobRequestConditions()
     .setLeaseId("leaseId");
 Consumer<BlobQueryError> errorConsumer = System.out::println;
 Consumer<BlobQueryProgress> progressConsumer = progress -> System.out.println("total blob bytes read: "
     + progress.getBytesScanned());
 BlobQueryOptions queryOptions = new BlobQueryOptions(expression)
     .setInputSerialization(input)
     .setOutputSerialization(output)
     .setRequestConditions(requestConditions)
     .setErrorConsumer(errorConsumer)
     .setProgressConsumer(progressConsumer);

 InputStream inputStream = client.openQueryInputStreamWithResponse(queryOptions).getValue();
 // Now you can read from the input stream like you would normally.

Parameters:

queryOptions - BlobQueryOptions.

Returns:

A response containing status code and HTTP headers including an InputStream object that represents the stream to use for reading the query response.

openSeekableByteChannelRead

public BlobSeekableByteChannelReadResult openSeekableByteChannelRead(BlobSeekableByteChannelReadOptions options, Context context)

Opens a seekable byte channel in read-only mode to download the blob.

Parameters:

context - Context

Returns:

A SeekableByteChannel that represents the channel to use for reading from the blob.

query

public void query(OutputStream stream, String expression)

Queries an entire blob into an output stream.

For more information, see the Azure Docs

Code Samples

ByteArrayOutputStream queryData = new ByteArrayOutputStream();
 String expression = "SELECT * from BlobStorage";
 client.query(queryData, expression);
 System.out.println("Query completed.");

Parameters:

stream - A non-null OutputStream instance where the downloaded data will be written.
expression - The query expression.

queryWithResponse

public BlobQueryResponse queryWithResponse(BlobQueryOptions queryOptions, Duration timeout, Context context)

Queries an entire blob into an output stream.

For more information, see the Azure Docs

Code Samples

ByteArrayOutputStream queryData = new ByteArrayOutputStream();
 String expression = "SELECT * from BlobStorage";
 BlobQueryJsonSerialization input = new BlobQueryJsonSerialization()
     .setRecordSeparator('\n');
 BlobQueryDelimitedSerialization output = new BlobQueryDelimitedSerialization()
     .setEscapeChar('\0')
     .setColumnSeparator(',')
     .setRecordSeparator('\n')
     .setFieldQuote('\'')
     .setHeadersPresent(true);
 BlobRequestConditions requestConditions = new BlobRequestConditions().setLeaseId(leaseId);
 Consumer<BlobQueryError> errorConsumer = System.out::println;
 Consumer<BlobQueryProgress> progressConsumer = progress -> System.out.println("total blob bytes read: "
     + progress.getBytesScanned());
 BlobQueryOptions queryOptions = new BlobQueryOptions(expression, queryData)
     .setInputSerialization(input)
     .setOutputSerialization(output)
     .setRequestConditions(requestConditions)
     .setErrorConsumer(errorConsumer)
     .setProgressConsumer(progressConsumer);
 System.out.printf("Query completed with status %d%n",
     client.queryWithResponse(queryOptions, timeout, new Context(key1, value1))
         .getStatusCode());

Parameters:

queryOptions - BlobQueryOptions.
timeout - An optional timeout value beyond which a RuntimeException will be raised.
context - Additional context that is passed through the Http pipeline during the service call.

Returns:

A response containing status code and HTTP headers.

setAccessTier

public void setAccessTier(AccessTier tier)

Sets the tier on a blob. The operation is allowed on a page blob in a premium storage account or a block blob in a blob storage or GPV2 account. A premium page blob's tier determines the allowed size, IOPS, and bandwidth of the blob. A block blob's tier determines the Hot/Cool/Archive storage type. This does not update the blob's etag.

Code Samples

client.setAccessTier(AccessTier.HOT);
 System.out.println("Set tier completed.");

For more information, see the Azure Docs

Parameters:

tier - The new tier for the blob.

setAccessTierWithResponse

public Response setAccessTierWithResponse(AccessTier tier, RehydratePriority priority, String leaseId, Duration timeout, Context context)

Sets the tier on a blob. The operation is allowed on a page blob in a premium storage account or a block blob in a blob storage or GPV2 account. A premium page blob's tier determines the allowed size, IOPS, and bandwidth of the blob. A block blob's tier determines the Hot/Cool/Archive storage type. This does not update the blob's etag.

Code Samples

System.out.printf("Set tier completed with status code %d%n",
     client.setAccessTierWithResponse(AccessTier.HOT, RehydratePriority.STANDARD, leaseId, timeout,
         new Context(key2, value2)).getStatusCode());

For more information, see the Azure Docs

Parameters:

tier - The new tier for the blob.
priority - Optional priority to set for re-hydrating blobs.
leaseId - The lease ID the active lease on the blob must match.
timeout - An optional timeout value beyond which a RuntimeException will be raised.
context - Additional context that is passed through the Http pipeline during the service call.

Returns:

A response containing status code and HTTP headers.

setAccessTierWithResponse

public Response setAccessTierWithResponse(BlobSetAccessTierOptions options, Duration timeout, Context context)

Sets the tier on a blob. The operation is allowed on a page blob in a premium storage account or a block blob in a blob storage or GPV2 account. A premium page blob's tier determines the allowed size, IOPS, and bandwidth of the blob. A block blob's tier determines the Hot/Cool/Archive storage type. This does not update the blob's etag.

Code Samples

System.out.printf("Set tier completed with status code %d%n",
     client.setAccessTierWithResponse(new BlobSetAccessTierOptions(AccessTier.HOT)
         .setPriority(RehydratePriority.STANDARD)
         .setLeaseId(leaseId)
         .setTagsConditions(tags),
         timeout, new Context(key2, value2)).getStatusCode());

For more information, see the Azure Docs

Parameters:

timeout - An optional timeout value beyond which a RuntimeException will be raised.
context - Additional context that is passed through the Http pipeline during the service call.

Returns:

A response containing status code and HTTP headers.

setHttpHeaders

public void setHttpHeaders(BlobHttpHeaders headers)

Changes a blob's HTTP header properties. if only one HTTP header is updated, the others will all be erased. In order to preserve existing values, they must be passed alongside the header being changed.

Code Samples

client.setHttpHeaders(new BlobHttpHeaders()
     .setContentLanguage("en-US")
     .setContentType("binary"));
 System.out.println("Set HTTP headers completed");

For more information, see the Azure Docs

Parameters:

headers - BlobHttpHeaders

setHttpHeadersWithResponse

public Response setHttpHeadersWithResponse(BlobHttpHeaders headers, BlobRequestConditions requestConditions, Duration timeout, Context context)

Changes a blob's HTTP header properties. if only one HTTP header is updated, the others will all be erased. In order to preserve existing values, they must be passed alongside the header being changed.

Code Samples

BlobRequestConditions requestConditions = new BlobRequestConditions().setLeaseId(leaseId);

 System.out.printf("Set HTTP headers completed with status %d%n",
     client.setHttpHeadersWithResponse(new BlobHttpHeaders()
         .setContentLanguage("en-US")
         .setContentType("binary"), requestConditions, timeout, new Context(key1, value1))
         .getStatusCode());

For more information, see the Azure Docs

Parameters:

headers - BlobHttpHeaders
requestConditions - BlobRequestConditions
timeout - An optional timeout value beyond which a RuntimeException will be raised.
context - Additional context that is passed through the Http pipeline during the service call.

Returns:

A response containing status code and HTTP headers.

setImmutabilityPolicy

public BlobImmutabilityPolicy setImmutabilityPolicy(BlobImmutabilityPolicy immutabilityPolicy)

Sets the immutability policy on a blob, blob snapshot or blob version.

NOTE: Blob Versioning must be enabled on your storage account and the blob must be in a container with immutable storage with versioning enabled to call this API.

Code Samples

BlobImmutabilityPolicy policy = new BlobImmutabilityPolicy()
     .setPolicyMode(BlobImmutabilityPolicyMode.LOCKED)
     .setExpiryTime(OffsetDateTime.now().plusDays(1));
 BlobImmutabilityPolicy setPolicy = client.setImmutabilityPolicy(policy);
 System.out.println("Successfully completed setting the immutability policy");

Parameters:

immutabilityPolicy - BlobImmutabilityPolicy.

Returns:

The immutability policy.

setImmutabilityPolicyWithResponse

public Response setImmutabilityPolicyWithResponse(BlobImmutabilityPolicy immutabilityPolicy, BlobRequestConditions requestConditions, Duration timeout, Context context)

Sets the immutability policy on a blob, blob snapshot or blob version.

NOTE: Blob Versioning must be enabled on your storage account and the blob must be in a container with immutable storage with versioning enabled to call this API.

Code Samples

BlobImmutabilityPolicy immutabilityPolicy = new BlobImmutabilityPolicy()
     .setPolicyMode(BlobImmutabilityPolicyMode.LOCKED)
     .setExpiryTime(OffsetDateTime.now().plusDays(1));
 BlobRequestConditions requestConditions = new BlobRequestConditions()
     .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(1));
 Response<BlobImmutabilityPolicy> response = client.setImmutabilityPolicyWithResponse(immutabilityPolicy,
     requestConditions, timeout, new Context(key1, value1));
 System.out.println("Successfully completed setting the immutability policy");

Parameters:

immutabilityPolicy - BlobImmutabilityPolicy.
requestConditions - BlobRequestConditions
timeout - An optional timeout value beyond which a RuntimeException will be raised.
context - Additional context that is passed through the Http pipeline during the service call.

Returns:

A response containing the immutability policy.

setLegalHold

public BlobLegalHoldResult setLegalHold(boolean legalHold)

Sets a legal hold on the blob.

NOTE: Blob Versioning must be enabled on your storage account and the blob must be in a container with immutable storage with versioning enabled to call this API.

Code Samples

System.out.println("Legal hold status: " + client.setLegalHold(true));

Parameters:

legalHold - Whether you want a legal hold on the blob.

Returns:

The legal hold result.

setLegalHoldWithResponse

public Response setLegalHoldWithResponse(boolean legalHold, Duration timeout, Context context)

Sets a legal hold on the blob.

NOTE: Blob Versioning must be enabled on your storage account and the blob must be in a container with immutable storage with versioning enabled to call this API.

Code Samples

System.out.println("Legal hold status: " + client.setLegalHoldWithResponse(true, timeout,
     new Context(key1, value1)));

Parameters:

legalHold - Whether you want a legal hold on the blob.
timeout - An optional timeout value beyond which a RuntimeException will be raised.
context - Additional context that is passed through the Http pipeline during the service call.

Returns:

A response containing the legal hold result.

setMetadata

public void setMetadata(Map metadata)

Changes a blob's metadata. The specified metadata in this method will replace existing metadata. If old values must be preserved, they must be downloaded and included in the call to this method.

Code Samples

client.setMetadata(Collections.singletonMap("metadata", "value"));
 System.out.println("Set metadata completed");

For more information, see the Azure Docs

Parameters:

metadata - Metadata to associate with the blob. If there is leading or trailing whitespace in any metadata key or value, it must be removed or encoded.

setMetadataWithResponse

public Response setMetadataWithResponse(Map metadata, BlobRequestConditions requestConditions, Duration timeout, Context context)

Changes a blob's metadata. The specified metadata in this method will replace existing metadata. If old values must be preserved, they must be downloaded and included in the call to this method.

Code Samples

BlobRequestConditions requestConditions = new BlobRequestConditions().setLeaseId(leaseId);

 System.out.printf("Set metadata completed with status %d%n",
     client.setMetadataWithResponse(Collections.singletonMap("metadata", "value"), requestConditions, timeout,
         new Context(key1, value1)).getStatusCode());

For more information, see the Azure Docs

Parameters:

metadata - Metadata to associate with the blob. If there is leading or trailing whitespace in any metadata key or value, it must be removed or encoded.
requestConditions - BlobRequestConditions
timeout - An optional timeout value beyond which a RuntimeException will be raised.
context - Additional context that is passed through the Http pipeline during the service call.

Returns:

A response containing status code and HTTP headers.

setTags

public void setTags(Map tags)

Sets user defined tags. The specified tags in this method will replace existing tags. If old values must be preserved, they must be downloaded and included in the call to this method.

Code Samples

client.setTags(Collections.singletonMap("tag", "value"));
 System.out.println("Set tag completed");

For more information, see the Azure Docs

Parameters:

tags - Tags to associate with the blob.

setTagsWithResponse

public Response setTagsWithResponse(BlobSetTagsOptions options, Duration timeout, Context context)

Sets user defined tags. The specified tags in this method will replace existing tags. If old values must be preserved, they must be downloaded and included in the call to this method.

Code Samples

System.out.printf("Set metadata completed with status %d%n",
     client.setTagsWithResponse(new BlobSetTagsOptions(Collections.singletonMap("tag", "value")), timeout,
         new Context(key1, value1))
         .getStatusCode());

For more information, see the Azure Docs

Parameters:

options - BlobSetTagsOptions
timeout - An optional timeout value beyond which a RuntimeException will be raised.
context - Additional context that is passed through the Http pipeline during the service call.

Returns:

A response containing status code and HTTP headers.

undelete

public void undelete()

Undelete restores the content and metadata of a soft-deleted blob and/or any associated soft-deleted snapshots.

Code Samples

client.undelete();
 System.out.println("Undelete completed");

For more information, see the Azure Docs

undeleteWithResponse

public Response undeleteWithResponse(Duration timeout, Context context)

Undelete restores the content and metadata of a soft-deleted blob and/or any associated soft-deleted snapshots.

Code Samples

System.out.printf("Undelete completed with status %d%n", client.undeleteWithResponse(timeout,
     new Context(key1, value1)).getStatusCode());

For more information, see the Azure Docs

Parameters:

timeout - An optional timeout value beyond which a RuntimeException will be raised.
context - Additional context that is passed through the Http pipeline during the service call.

Returns:

A response containing status code and HTTP headers.

Applies to