Class BlobClient
 This client is instantiated through BlobClientBuilder or retrieved via
 getBlobClient.
 
 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.
- 
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intIf a blob is known to be greater than 100MB, using a larger block size will trigger some server-side optimizations.static final intThe number of buffers to use if none is specified on the buffered upload method.static final intThe block size to use if none is specified in parallel operations.Fields inherited from class com.azure.storage.blob.specialized.BlobClientBase
accountName, blobName, containerName, serviceVersion - 
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedBlobClient(BlobAsyncClient client) Protected constructor for use byBlobClientBuilder.protectedBlobClient(BlobAsyncClient client, com.azure.core.http.HttpPipeline pipeline, String url, BlobServiceVersion serviceVersion, String accountName, String containerName, String blobName, String snapshot, CpkInfo customerProvidedKey, com.azure.storage.blob.implementation.models.EncryptionScope encryptionScope, String versionId) Protected constructor for use byBlobClientBuilder. - 
Method Summary
Modifier and TypeMethodDescriptionCreates a newAppendBlobClientassociated with this blob.Creates a newBlockBlobClientassociated with this blob.getCustomerProvidedKeyClient(CustomerProvidedKey customerProvidedKey) Creates a newBlobClientwith the specifiedcustomerProvidedKey.getEncryptionScopeClient(String encryptionScope) Creates a newBlobClientwith the specifiedencryptionScope.Creates a newPageBlobClientassociated with this blob.getSnapshotClient(String snapshot) Creates a newBlobClientlinked to thesnapshotof this blob resource.getVersionClient(String versionId) Creates a newBlobClientlinked to theversionof this blob resource.voidupload(com.azure.core.util.BinaryData data) Creates a new blob.voidupload(com.azure.core.util.BinaryData data, boolean overwrite) Creates a new blob, or updates the content of an existing blob.voidupload(InputStream data) Creates a new blob.voidupload(InputStream data, boolean overwrite) Creates a new blob, or updates the content of an existing blob.voidupload(InputStream data, long length) Creates a new blob.voidupload(InputStream data, long length, boolean overwrite) Creates a new blob, or updates the content of an existing blob.voiduploadFromFile(String filePath) Creates a new block blob.voiduploadFromFile(String filePath, boolean overwrite) Creates a new block blob, or updates the content of an existing block blob.voiduploadFromFile(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.com.azure.core.http.rest.Response<BlockBlobItem> uploadFromFileWithResponse(BlobUploadFromFileOptions options, Duration timeout, com.azure.core.util.Context context) Creates a new block blob, or updates the content of an existing block blob.com.azure.core.http.rest.Response<BlockBlobItem> uploadWithResponse(BlobParallelUploadOptions options, com.azure.core.util.Context context) Deprecated.com.azure.core.http.rest.Response<BlockBlobItem> uploadWithResponse(BlobParallelUploadOptions options, Duration timeout, com.azure.core.util.Context context) Creates a new blob, or updates the content of an existing blob.voiduploadWithResponse(InputStream data, long length, ParallelTransferOptions parallelTransferOptions, BlobHttpHeaders headers, Map<String, String> metadata, AccessTier tier, BlobRequestConditions requestConditions, Duration timeout, com.azure.core.util.Context context) Deprecated.Methods inherited from class com.azure.storage.blob.specialized.BlobClientBase
abortCopyFromUrl, abortCopyFromUrlWithResponse, beginCopy, beginCopy, beginCopy, copyFromUrl, copyFromUrlWithResponse, copyFromUrlWithResponse, createSnapshot, createSnapshotWithResponse, delete, deleteIfExists, deleteIfExistsWithResponse, deleteImmutabilityPolicy, deleteImmutabilityPolicyWithResponse, deleteWithResponse, download, downloadContent, downloadContentWithResponse, downloadContentWithResponse, downloadStream, downloadStreamWithResponse, downloadToFile, downloadToFile, downloadToFileWithResponse, downloadToFileWithResponse, downloadToFileWithResponse, downloadWithResponse, exists, existsWithResponse, generateSas, generateSas, generateSas, generateUserDelegationSas, generateUserDelegationSas, generateUserDelegationSas, getAccountInfo, getAccountInfoWithResponse, getAccountName, getAccountUrl, getBlobName, getBlobUrl, getContainerClient, getContainerName, getCustomerProvidedKey, getEncryptionScope, getHttpPipeline, getProperties, getPropertiesWithResponse, getServiceVersion, getSnapshotId, getTags, getTagsWithResponse, getVersionId, isSnapshot, openInputStream, openInputStream, openInputStream, openInputStream, openQueryInputStream, openQueryInputStreamWithResponse, openSeekableByteChannelRead, query, queryWithResponse, setAccessTier, setAccessTierWithResponse, setAccessTierWithResponse, setHttpHeaders, setHttpHeadersWithResponse, setImmutabilityPolicy, setImmutabilityPolicyWithResponse, setLegalHold, setLegalHoldWithResponse, setMetadata, setMetadataWithResponse, setTags, setTagsWithResponse, undelete, undeleteWithResponse 
- 
Field Details
- 
BLOB_DEFAULT_UPLOAD_BLOCK_SIZE
public static final int BLOB_DEFAULT_UPLOAD_BLOCK_SIZEThe block size to use if none is specified in parallel operations.- See Also:
 
 - 
BLOB_DEFAULT_NUMBER_OF_BUFFERS
public static final int BLOB_DEFAULT_NUMBER_OF_BUFFERSThe number of buffers to use if none is specified on the buffered upload method.- See Also:
 
 - 
BLOB_DEFAULT_HTBB_UPLOAD_BLOCK_SIZE
public static final int BLOB_DEFAULT_HTBB_UPLOAD_BLOCK_SIZEIf 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.- See Also:
 
 
 - 
 - 
Constructor Details
- 
BlobClient
Protected constructor for use byBlobClientBuilder.- Parameters:
 client- the async blob client
 - 
BlobClient
protected BlobClient(BlobAsyncClient client, com.azure.core.http.HttpPipeline pipeline, String url, BlobServiceVersion serviceVersion, String accountName, String containerName, String blobName, String snapshot, CpkInfo customerProvidedKey, com.azure.storage.blob.implementation.models.EncryptionScope encryptionScope, String versionId) Protected constructor for use byBlobClientBuilder.- Parameters:
 client- the async blob clientpipeline- 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, passnullto interact with the blob directly.customerProvidedKey- Customer provided key used during encryption of the blob's data on the server, passnullto allow the service to use its own encryption.encryptionScope- Encryption scope used during encryption of the blob's data on the server, passnullto allow the service to use its own encryption.versionId- The version identifier for the blob, passnullto interact with the latest blob version.
 
 - 
 - 
Method Details
- 
getSnapshotClient
Creates a newBlobClientlinked to thesnapshotof this blob resource.- Overrides:
 getSnapshotClientin classBlobClientBase- Parameters:
 snapshot- the identifier for a specific snapshot of this blob- Returns:
 - A 
BlobClientused to interact with the specific snapshot. 
 - 
getVersionClient
Creates a newBlobClientlinked to theversionof this blob resource.- Overrides:
 getVersionClientin classBlobClientBase- Parameters:
 versionId- the identifier for a specific version of this blob, passnullto interact with the latest blob version.- Returns:
 - A 
BlobClientused to interact with the specific version. 
 - 
getEncryptionScopeClient
Creates a newBlobClientwith the specifiedencryptionScope.- Overrides:
 getEncryptionScopeClientin classBlobClientBase- Parameters:
 encryptionScope- the encryption scope for the blob, passnullto use no encryption scope.- Returns:
 - a 
BlobClientwith the specifiedencryptionScope. 
 - 
getCustomerProvidedKeyClient
Creates a newBlobClientwith the specifiedcustomerProvidedKey.- Overrides:
 getCustomerProvidedKeyClientin classBlobClientBase- Parameters:
 customerProvidedKey- theCustomerProvidedKeyfor the blob, passnullto use no customer provided key.- Returns:
 - a 
BlobClientwith the specifiedcustomerProvidedKey. 
 - 
getAppendBlobClient
Creates a newAppendBlobClientassociated with this blob.- Returns:
 - A 
AppendBlobClientassociated with this blob. 
 - 
getBlockBlobClient
Creates a newBlockBlobClientassociated with this blob.- Returns:
 - A 
BlockBlobClientassociated with this blob. 
 - 
getPageBlobClient
Creates a newPageBlobClientassociated with this blob.- Returns:
 - A 
PageBlobClientassociated with this blob. 
 - 
upload
Creates a new blob. By default this method will not overwrite an existing blob.- Parameters:
 data- The data to write to the blob. The data must be markable. This is in order to support retries. If the data is not markable, consider opening aBlobOutputStreamand writing to the returned stream. Alternatively, consider wrapping your data source in aBufferedInputStreamto add mark support.
 - 
upload
Creates a new blob. By default this method will not overwrite an existing blob.- Parameters:
 data- The data to write to the blob. The data must be markable. This is in order to support retries. If the data is not markable, consider opening aBlobOutputStreamand writing to the returned stream. Alternatively, consider wrapping your data source in aBufferedInputStreamto add mark support.length- The exact length of the data. It is important that this value match precisely the length of the data provided in theInputStream.
 - 
upload
Creates a new blob, or updates the content of an existing blob.- Parameters:
 data- The data to write to the blob. The data must be markable. This is in order to support retries. If the data is not markable, consider opening aBlobOutputStreamand writing to the returned stream. Alternatively, consider wrapping your data source in aBufferedInputStreamto add mark support.overwrite- Whether or not to overwrite, should data exist on the blob.
 - 
upload
Creates a new blob, or updates the content of an existing blob.- Parameters:
 data- The data to write to the blob. The data must be markable. This is in order to support retries. If the data is not markable, consider opening aBlobOutputStreamand writing to the returned stream. Alternatively, consider wrapping your data source in aBufferedInputStreamto add mark support.length- The exact length of the data. It is important that this value match precisely the length of the data provided in theInputStream.overwrite- Whether or not to overwrite, should data exist on the blob.
 - 
upload
public void upload(com.azure.core.util.BinaryData data) Creates a new blob. By default this method will not overwrite an existing blob.- Parameters:
 data- The data to write to the blob.
 - 
upload
public void upload(com.azure.core.util.BinaryData data, boolean overwrite) Creates a new blob, or updates the content of an existing blob.- Parameters:
 data- The data to write to the blob.overwrite- Whether or not to overwrite, should data exist on the blob.
 - 
uploadWithResponse
@Deprecated public void uploadWithResponse(InputStream data, long length, ParallelTransferOptions parallelTransferOptions, BlobHttpHeaders headers, Map<String, String> metadata, AccessTier tier, BlobRequestConditions requestConditions, Duration timeout, com.azure.core.util.Context context) Deprecated.Creates a new blob, or updates the content of an existing blob.To avoid overwriting, pass "*" to
BlobRequestConditions.setIfNoneMatch(String).- Parameters:
 data- The data to write to the blob. The data must be markable. This is in order to support retries. If the data is not markable, consider opening aBlobOutputStreamand writing to the returned stream. Alternatively, consider wrapping your data source in aBufferedInputStreamto add mark support.length- The exact length of the data. It is important that this value match precisely the length of the data provided in theInputStream.parallelTransferOptions-ParallelTransferOptionsused to configure buffered uploading.headers-BlobHttpHeadersmetadata- 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.tier-AccessTierfor the destination blob.requestConditions-BlobRequestConditionstimeout- An optional timeout value beyond which aRuntimeExceptionwill be raised.context- Additional context that is passed through the Http pipeline during the service call.
 - 
uploadWithResponse
@Deprecated public com.azure.core.http.rest.Response<BlockBlobItem> uploadWithResponse(BlobParallelUploadOptions options, com.azure.core.util.Context context) Deprecated.Creates a new blob, or updates the content of an existing blob.To avoid overwriting, pass "*" to
BlobRequestConditions.setIfNoneMatch(String).- Parameters:
 options-BlobParallelUploadOptionscontext- Additional context that is passed through the Http pipeline during the service call.- Returns:
 - Information about the uploaded block blob.
 
 - 
uploadWithResponse
public com.azure.core.http.rest.Response<BlockBlobItem> uploadWithResponse(BlobParallelUploadOptions options, Duration timeout, com.azure.core.util.Context context) Creates a new blob, or updates the content of an existing blob.To avoid overwriting, pass "*" to
BlobRequestConditions.setIfNoneMatch(String).- Parameters:
 options-BlobParallelUploadOptionstimeout- An optional timeout value beyond which aRuntimeExceptionwill be raised.context- Additional context that is passed through the Http pipeline during the service call.- Returns:
 - Information about the uploaded block blob.
 
 - 
uploadFromFile
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()); }- Parameters:
 filePath- Path of the file to upload- Throws:
 UncheckedIOException- If an I/O error occurs
 - 
uploadFromFile
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()); }- Parameters:
 filePath- Path of the file to uploadoverwrite- Whether or not to overwrite, should the blob already exist- Throws:
 UncheckedIOException- If an I/O error occurs
 - 
uploadFromFile
public void 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
BlobRequestConditions.setIfNoneMatch(String).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()); }- Parameters:
 filePath- Path of the file to uploadparallelTransferOptions-ParallelTransferOptionsto use to upload from file. Number of parallel transfers parameter is ignored.headers-BlobHttpHeadersmetadata- 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.tier-AccessTierfor the uploaded blobrequestConditions-BlobRequestConditionstimeout- An optional timeout value beyond which aRuntimeExceptionwill be raised.- Throws:
 UncheckedIOException- If an I/O error occurs
 - 
uploadFromFileWithResponse
public com.azure.core.http.rest.Response<BlockBlobItem> uploadFromFileWithResponse(BlobUploadFromFileOptions options, Duration timeout, com.azure.core.util.Context context) Creates a new block blob, or updates the content of an existing block blob.To avoid overwriting, pass "*" to
BlobRequestConditions.setIfNoneMatch(String).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()); }- Parameters:
 options-BlobUploadFromFileOptionstimeout- An optional timeout value beyond which aRuntimeExceptionwill be raised.context- Additional context that is passed through the Http pipeline during the service call.- Returns:
 - Information about the uploaded block blob.
 - Throws:
 UncheckedIOException- If an I/O error occurs
 
 - 
 
uploadWithResponse(BlobParallelUploadOptions, Duration, Context)