BlobClient Class

Definition

This class provides a client that contains generic blob operations for Azure Storage Blobs. Operations allowed by the client are uploading and downloading, copying a blob, retrieving and setting metadata, retrieving and setting HTTP headers, and deleting and un-deleting a blob.

This client is instantiated through BlobClientBuilder or retrieved via getBlobClient(String blobName).

For operations on a specific blob type (i.e append, block, or page) use getAppendBlobClient(), getBlockBlobClient(), or getPageBlobClient() to construct a client that allows blob specific operations.

Please refer to the Azure Docs for more information.

public class BlobClient extends BlobClientBase
Inheritance
java.lang.Object
BlobClient

Inherited Members

BlobClientBase.abortCopyFromUrl(String copyId) BlobClientBase.abortCopyFromUrlWithResponse(String copyId, String leaseId, Duration timeout, Context context) BlobClientBase.beginCopy(BlobBeginCopyOptions options) BlobClientBase.beginCopy(String sourceUrl, Duration pollInterval) BlobClientBase.beginCopy(String sourceUrl, Map<String,String> metadata, AccessTier tier, RehydratePriority priority, RequestConditions sourceModifiedRequestConditions, BlobRequestConditions destRequestConditions, Duration pollInterval) BlobClientBase.copyFromUrl(String copySource) BlobClientBase.copyFromUrlWithResponse(BlobCopyFromUrlOptions options, Duration timeout, Context context) BlobClientBase.copyFromUrlWithResponse(String copySource, Map<String,String> metadata, AccessTier tier, RequestConditions sourceModifiedRequestConditions, BlobRequestConditions destRequestConditions, Duration timeout, Context context) BlobClientBase.createSnapshot() BlobClientBase.createSnapshotWithResponse(Map<String,String> metadata, BlobRequestConditions requestConditions, Duration timeout, Context context) BlobClientBase.delete() BlobClientBase.deleteImmutabilityPolicy() BlobClientBase.deleteImmutabilityPolicyWithResponse(Duration timeout, Context context) BlobClientBase.deleteWithResponse(DeleteSnapshotsOptionType deleteBlobSnapshotOptions, BlobRequestConditions requestConditions, Duration timeout, Context context) BlobClientBase.download(OutputStream stream) BlobClientBase.downloadContent() BlobClientBase.downloadContentWithResponse(DownloadRetryOptions options, BlobRequestConditions requestConditions, Duration timeout, Context context) BlobClientBase.downloadStream(OutputStream stream) BlobClientBase.downloadStreamWithResponse(OutputStream stream, BlobRange range, DownloadRetryOptions options, BlobRequestConditions requestConditions, boolean getRangeContentMd5, Duration timeout, Context context) BlobClientBase.downloadToFile(String filePath) BlobClientBase.downloadToFile(String filePath, boolean overwrite) BlobClientBase.downloadToFileWithResponse(BlobDownloadToFileOptions options, Duration timeout, Context context) BlobClientBase.downloadToFileWithResponse(String filePath, BlobRange range, ParallelTransferOptions parallelTransferOptions, DownloadRetryOptions downloadRetryOptions, BlobRequestConditions requestConditions, boolean rangeGetContentMd5, Duration timeout, Context context) BlobClientBase.downloadToFileWithResponse(String filePath, BlobRange range, ParallelTransferOptions parallelTransferOptions, DownloadRetryOptions downloadRetryOptions, BlobRequestConditions requestConditions, boolean rangeGetContentMd5, Set<OpenOption> openOptions, Duration timeout, Context context) BlobClientBase.downloadWithResponse(OutputStream stream, BlobRange range, DownloadRetryOptions options, BlobRequestConditions requestConditions, boolean getRangeContentMd5, Duration timeout, Context context) BlobClientBase.exists() BlobClientBase.existsWithResponse(Duration timeout, Context context) BlobClientBase.generateSas(BlobServiceSasSignatureValues blobServiceSasSignatureValues) BlobClientBase.generateSas(BlobServiceSasSignatureValues blobServiceSasSignatureValues, Context context) BlobClientBase.generateUserDelegationSas(BlobServiceSasSignatureValues blobServiceSasSignatureValues, UserDelegationKey userDelegationKey) BlobClientBase.generateUserDelegationSas(BlobServiceSasSignatureValues blobServiceSasSignatureValues, UserDelegationKey userDelegationKey, String accountName, Context context) BlobClientBase.getAccountInfo() BlobClientBase.getAccountInfoWithResponse(Duration timeout, Context context) BlobClientBase.getAccountName() BlobClientBase.getAccountUrl() BlobClientBase.getBlobName() BlobClientBase.getBlobUrl() BlobClientBase.getContainerClient() BlobClientBase.getContainerName() BlobClientBase.getCustomerProvidedKey() BlobClientBase.getCustomerProvidedKeyClient(CustomerProvidedKey customerProvidedKey) BlobClientBase.getEncryptionScopeClient(String encryptionScope) BlobClientBase.getHttpPipeline() BlobClientBase.getProperties() BlobClientBase.getPropertiesWithResponse(BlobRequestConditions requestConditions, Duration timeout, Context context) BlobClientBase.getServiceVersion() BlobClientBase.getSnapshotClient(String snapshot) BlobClientBase.getSnapshotId() BlobClientBase.getTags() BlobClientBase.getTagsWithResponse(BlobGetTagsOptions options, Duration timeout, Context context) BlobClientBase.getVersionClient(String versionId) BlobClientBase.getVersionId() BlobClientBase.isSnapshot() BlobClientBase.openInputStream() BlobClientBase.openInputStream(BlobRange range, BlobRequestConditions requestConditions) BlobClientBase.openInputStream(BlobInputStreamOptions options) BlobClientBase.openQueryInputStream(String expression) BlobClientBase.openQueryInputStreamWithResponse(BlobQueryOptions queryOptions) BlobClientBase.query(OutputStream stream, String expression) BlobClientBase.queryWithResponse(BlobQueryOptions queryOptions, Duration timeout, Context context) BlobClientBase.setAccessTier(AccessTier tier) BlobClientBase.setAccessTierWithResponse(AccessTier tier, RehydratePriority priority, String leaseId, Duration timeout, Context context) BlobClientBase.setAccessTierWithResponse(BlobSetAccessTierOptions options, Duration timeout, Context context) BlobClientBase.setHttpHeaders(BlobHttpHeaders headers) BlobClientBase.setHttpHeadersWithResponse(BlobHttpHeaders headers, BlobRequestConditions requestConditions, Duration timeout, Context context) BlobClientBase.setImmutabilityPolicy(BlobImmutabilityPolicy immutabilityPolicy) BlobClientBase.setImmutabilityPolicyWithResponse(BlobImmutabilityPolicy immutabilityPolicy, BlobRequestConditions requestConditions, Duration timeout, Context context) BlobClientBase.setLegalHold(boolean legalHold) BlobClientBase.setLegalHoldWithResponse(boolean legalHold, Duration timeout, Context context) BlobClientBase.setMetadata(Map<String,String> metadata) BlobClientBase.setMetadataWithResponse(Map<String,String> metadata, BlobRequestConditions requestConditions, Duration timeout, Context context) BlobClientBase.setTags(Map<String,String> tags) BlobClientBase.setTagsWithResponse(BlobSetTagsOptions options, Duration timeout, Context context) BlobClientBase.undelete() BlobClientBase.undeleteWithResponse(Duration timeout, Context context) java.lang.Object.clone() java.lang.Object.equals(java.lang.Object) java.lang.Object.finalize() java.lang.Object.getClass() java.lang.Object.hashCode() java.lang.Object.notify() java.lang.Object.notifyAll() java.lang.Object.toString() java.lang.Object.wait() java.lang.Object.wait(long) java.lang.Object.wait(long,int)

Constructors

BlobClient(BlobAsyncClient client)

Protected constructor for use by BlobClientBuilder.

Fields

BLOB_DEFAULT_HTBB_UPLOAD_BLOCK_SIZE

If a blob is known to be greater than 100MB, using a larger block size will trigger some server-side optimizations. If the block size is not set and the size of the blob is known to be greater than 100MB, this value will be used.

BLOB_DEFAULT_NUMBER_OF_BUFFERS

The number of buffers to use if none is specied on the buffered upload method.

BLOB_DEFAULT_UPLOAD_BLOCK_SIZE

The block size to use if none is specified in parallel operations.

Methods

getAppendBlobClient()

Creates a new AppendBlobClient associated with this blob.

getBlockBlobClient()

Creates a new BlockBlobClient associated with this blob.

getCustomerProvidedKeyClient(CustomerProvidedKey customerProvidedKey)

Creates a new BlobClient with the specified customerProvidedKey.

getEncryptionScopeClient(String encryptionScope)

Creates a new BlobClient with the specified encryptionScope.

getPageBlobClient()

Creates a new PageBlobClient associated with this blob.

getSnapshotClient(String snapshot)

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

getVersionClient(String versionId)

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

upload(BinaryData data)

Creates a new blob. By default this method will not overwrite an existing blob.

upload(BinaryData data, boolean overwrite)

Creates a new blob, or updates the content of an existing blob.

upload(InputStream data, long length)

Creates a new blob. By default this method will not overwrite an existing blob.

upload(InputStream data, long length, boolean overwrite)

Creates a new blob, or updates the content of an existing blob.

uploadFromFile(String filePath)

Creates a new block blob. By default this method will not overwrite an existing blob.

Code Samples

try {
     client.uploadFromFile(filePath);
     System.out.println("Upload from file succeeded");
 } catch (UncheckedIOException ex) {
     System.err.printf("Failed to upload from file %s%n", ex.getMessage());
 }
uploadFromFile(String filePath, boolean overwrite)

Creates a new block blob, or updates the content of an existing block blob.

Code Samples

try {
     boolean overwrite = false;
     client.uploadFromFile(filePath, overwrite);
     System.out.println("Upload from file succeeded");
 } catch (UncheckedIOException ex) {
     System.err.printf("Failed to upload from file %s%n", ex.getMessage());
 }
uploadFromFile(String filePath, ParallelTransferOptions parallelTransferOptions, BlobHttpHeaders headers, Map<String,String> metadata, AccessTier tier, BlobRequestConditions requestConditions, Duration timeout)

Creates a new block blob, or updates the content of an existing block blob.

To avoid overwriting, pass "*" to setIfNoneMatch(String ifNoneMatch).

Code Samples

BlobHttpHeaders headers = new BlobHttpHeaders()
     .setContentMd5("data".getBytes(StandardCharsets.UTF_8))
     .setContentLanguage("en-US")
     .setContentType("binary");

 Map<String, String> metadata = Collections.singletonMap("metadata", "value");
 BlobRequestConditions requestConditions = new BlobRequestConditions()
     .setLeaseId(leaseId)
     .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
 Long blockSize = 100L * 1024L * 1024L; // 100 MB;
 ParallelTransferOptions parallelTransferOptions = new ParallelTransferOptions().setBlockSizeLong(blockSize);

 try {
     client.uploadFromFile(filePath, parallelTransferOptions, headers, metadata,
         AccessTier.HOT, requestConditions, timeout);
     System.out.println("Upload from file succeeded");
 } catch (UncheckedIOException ex) {
     System.err.printf("Failed to upload from file %s%n", ex.getMessage());
 }
uploadFromFileWithResponse(BlobUploadFromFileOptions options, Duration timeout, Context context)

Creates a new block blob, or updates the content of an existing block blob.

To avoid overwriting, pass "*" to setIfNoneMatch(String ifNoneMatch).

Code Samples

BlobHttpHeaders headers = new BlobHttpHeaders()
     .setContentMd5("data".getBytes(StandardCharsets.UTF_8))
     .setContentLanguage("en-US")
     .setContentType("binary");

 Map<String, String> metadata = Collections.singletonMap("metadata", "value");
 Map<String, String> tags = Collections.singletonMap("tag", "value");
 BlobRequestConditions requestConditions = new BlobRequestConditions()
     .setLeaseId(leaseId)
     .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
 Long blockSize = 100 * 1024 * 1024L; // 100 MB;
 ParallelTransferOptions parallelTransferOptions = new ParallelTransferOptions().setBlockSizeLong(blockSize);

 try {
     client.uploadFromFileWithResponse(new BlobUploadFromFileOptions(filePath)
         .setParallelTransferOptions(parallelTransferOptions).setHeaders(headers).setMetadata(metadata)
         .setTags(tags).setTier(AccessTier.HOT).setRequestConditions(requestConditions), timeout,
         new Context(key2, value2));
     System.out.println("Upload from file succeeded");
 } catch (UncheckedIOException ex) {
     System.err.printf("Failed to upload from file %s%n", ex.getMessage());
 }
uploadWithResponse(BlobParallelUploadOptions options, Context context)

Creates a new blob, or updates the content of an existing blob.

To avoid overwriting, pass "*" to setIfNoneMatch(String ifNoneMatch).

uploadWithResponse(BlobParallelUploadOptions options, Duration timeout, Context context)

Creates a new blob, or updates the content of an existing blob.

To avoid overwriting, pass "*" to setIfNoneMatch(String ifNoneMatch).

uploadWithResponse(InputStream data, long length, ParallelTransferOptions parallelTransferOptions, BlobHttpHeaders headers, Map<String,String> metadata, AccessTier tier, BlobRequestConditions requestConditions, Duration timeout, Context context)

Creates a new blob, or updates the content of an existing blob.

To avoid overwriting, pass "*" to setIfNoneMatch(String ifNoneMatch).

Applies to