Class BlockBlobAsyncClient
SpecializedBlobClientBuilder
or via the method
BlobAsyncClient.getBlockBlobAsyncClient()
. This class does not hold any state about a particular blob, but is
instead a convenient way of sending appropriate requests to the resource on the service.
Please refer to the Azure Docs for more information.
Note this client is an async client that returns reactive responses from Spring Reactor Core project
(https://projectreactor.io/). Calling the methods in this client will NOT start the actual network
operation, until .subscribe()
is called on the reactive response. You can simply convert one of these
responses to a CompletableFuture
object through Mono.toFuture()
.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Indicates the maximum number of blocks allowed in a block blob.static final int
Deprecated.static final long
Indicates the maximum number of bytes that can be sent in a call to stageBlock.static final int
Deprecated.static final long
Indicates the maximum number of bytes that can be sent in a call to upload.Fields inherited from class com.azure.storage.blob.specialized.BlobAsyncClientBase
accountName, azureBlobStorage, blobName, containerName, encryptionScope, serviceVersion
-
Method Summary
Modifier and TypeMethodDescriptioncommitBlockList
(List<String> base64BlockIds) Writes a blob by specifying the list of block IDs that are to make up the blob.commitBlockList
(List<String> base64BlockIds, boolean overwrite) Writes a blob by specifying the list of block IDs that are to make up the blob.Mono<com.azure.core.http.rest.Response<BlockBlobItem>>
Writes a blob by specifying the list of block IDs that are to make up the blob.Mono<com.azure.core.http.rest.Response<BlockBlobItem>>
commitBlockListWithResponse
(List<String> base64BlockIds, BlobHttpHeaders headers, Map<String, String> metadata, AccessTier tier, BlobRequestConditions requestConditions) Writes a blob by specifying the list of block IDs that are to make up the blob.getCustomerProvidedKeyAsyncClient
(CustomerProvidedKey customerProvidedKey) Creates a newBlockBlobAsyncClient
with the specifiedcustomerProvidedKey
.getEncryptionScopeAsyncClient
(String encryptionScope) Creates a newBlockBlobAsyncClient
with the specifiedencryptionScope
.listBlocks
(BlockListType listType) Returns the list of blocks that have been uploaded as part of a block blob using the specified block list filter.listBlocksWithResponse
(BlockListType listType, String leaseId) Returns the list of blocks that have been uploaded as part of a block blob using the specified block list filter.Returns the list of blocks that have been uploaded as part of a block blob using the specified block list filter.stageBlock
(String base64BlockId, com.azure.core.util.BinaryData data) Uploads the specified block to the block blob's "staging area" to be later committed by a call to commitBlockList.stageBlock
(String base64BlockId, Flux<ByteBuffer> data, long length) Uploads the specified block to the block blob's "staging area" to be later committed by a call to commitBlockList.stageBlockFromUrl
(String base64BlockId, String sourceUrl, BlobRange sourceRange) Creates a new block to be committed as part of a blob where the contents are read from a URL.Creates a new block to be committed as part of a blob where the contents are read from a URL.stageBlockFromUrlWithResponse
(String base64BlockId, String sourceUrl, BlobRange sourceRange, byte[] sourceContentMd5, String leaseId, BlobRequestConditions sourceRequestConditions) Creates a new block to be committed as part of a blob where the contents are read from a URL.Uploads the specified block to the block blob's "staging area" to be later committed by a call to commitBlockList.stageBlockWithResponse
(String base64BlockId, Flux<ByteBuffer> data, long length, byte[] contentMd5, String leaseId) Uploads the specified block to the block blob's "staging area" to be later committed by a call to commitBlockList.upload
(com.azure.core.util.BinaryData data) Creates a new block blob.upload
(com.azure.core.util.BinaryData data, boolean overwrite) Creates a new block blob, or updates the content of an existing block blob.upload
(Flux<ByteBuffer> data, long length) Creates a new block blob.upload
(Flux<ByteBuffer> data, long length, boolean overwrite) Creates a new block blob, or updates the content of an existing block blob.uploadFromUrl
(String sourceUrl) Creates a new block blob, or updates the content of an existing block blob.uploadFromUrl
(String sourceUrl, boolean overwrite) Creates a new block blob, or updates the content of an existing block blob.Mono<com.azure.core.http.rest.Response<BlockBlobItem>>
Creates a new block blob, or updates the content of an existing block blob.Mono<com.azure.core.http.rest.Response<BlockBlobItem>>
Creates a new block blob, or updates the content of an existing block blob.Mono<com.azure.core.http.rest.Response<BlockBlobItem>>
uploadWithResponse
(Flux<ByteBuffer> data, long length, BlobHttpHeaders headers, Map<String, String> metadata, AccessTier tier, byte[] contentMd5, BlobRequestConditions requestConditions) Creates a new block blob, or updates the content of an existing block blob.Methods inherited from class com.azure.storage.blob.specialized.BlobAsyncClientBase
abortCopyFromUrl, abortCopyFromUrlWithResponse, beginCopy, beginCopy, beginCopy, copyFromUrl, copyFromUrlWithResponse, copyFromUrlWithResponse, createSnapshot, createSnapshotWithResponse, delete, deleteIfExists, deleteIfExistsWithResponse, deleteImmutabilityPolicy, deleteImmutabilityPolicyWithResponse, deleteWithResponse, download, downloadContent, downloadContentWithResponse, downloadStream, downloadStreamWithResponse, downloadToFile, downloadToFile, downloadToFileWithResponse, downloadToFileWithResponse, downloadToFileWithResponse, downloadWithResponse, exists, existsWithResponse, generateSas, generateSas, generateUserDelegationSas, generateUserDelegationSas, getAccountInfo, getAccountInfoWithResponse, getAccountName, getAccountUrl, getBlobName, getBlobUrl, getContainerAsyncClient, getContainerName, getCustomerProvidedKey, getEncryptionScope, getHttpPipeline, getProperties, getPropertiesWithResponse, getServiceVersion, getSnapshotClient, getSnapshotId, getTags, getTagsWithResponse, getVersionClient, getVersionId, isSnapshot, query, queryWithResponse, setAccessTier, setAccessTierWithResponse, setAccessTierWithResponse, setHttpHeaders, setHttpHeadersWithResponse, setImmutabilityPolicy, setImmutabilityPolicyWithResponse, setLegalHold, setLegalHoldWithResponse, setMetadata, setMetadataWithResponse, setTags, setTagsWithResponse, undelete, undeleteWithResponse
-
Field Details
-
MAX_UPLOAD_BLOB_BYTES
Deprecated.Indicates the maximum number of bytes that can be sent in a call to upload.- See Also:
-
MAX_UPLOAD_BLOB_BYTES_LONG
public static final long MAX_UPLOAD_BLOB_BYTES_LONGIndicates the maximum number of bytes that can be sent in a call to upload.- See Also:
-
MAX_STAGE_BLOCK_BYTES
Deprecated.Indicates the maximum number of bytes that can be sent in a call to stageBlock.- See Also:
-
MAX_STAGE_BLOCK_BYTES_LONG
public static final long MAX_STAGE_BLOCK_BYTES_LONGIndicates the maximum number of bytes that can be sent in a call to stageBlock.- See Also:
-
MAX_BLOCKS
public static final int MAX_BLOCKSIndicates the maximum number of blocks allowed in a block blob.- See Also:
-
-
Method Details
-
getEncryptionScopeAsyncClient
Creates a newBlockBlobAsyncClient
with the specifiedencryptionScope
.- Overrides:
getEncryptionScopeAsyncClient
in classBlobAsyncClientBase
- Parameters:
encryptionScope
- the encryption scope for the blob, passnull
to use no encryption scope.- Returns:
- a
BlockBlobAsyncClient
with the specifiedencryptionScope
.
-
getCustomerProvidedKeyAsyncClient
public BlockBlobAsyncClient getCustomerProvidedKeyAsyncClient(CustomerProvidedKey customerProvidedKey) Creates a newBlockBlobAsyncClient
with the specifiedcustomerProvidedKey
.- Overrides:
getCustomerProvidedKeyAsyncClient
in classBlobAsyncClientBase
- Parameters:
customerProvidedKey
- theCustomerProvidedKey
for the blob, passnull
to use no customer provided key.- Returns:
- a
BlockBlobAsyncClient
with the specifiedcustomerProvidedKey
.
-
upload
Creates a new block blob. By default, this method will not overwrite an existing blob. Updating an existing block blob overwrites any existing metadata on the blob. Partial updates are not supported with PutBlob; the content of the existing blob is overwritten with the new content. To perform a partial update of a block blob's, use PutBlock and PutBlockList. For more information, see the Azure Docs.Note that the data passed must be replayable if retries are enabled (the default). In other words, the
Flux
must produce the same data each time it is subscribed to.Code Samples
client.upload(data, length).subscribe(response -> System.out.printf("Uploaded BlockBlob MD5 is %s%n", Base64.getEncoder().encodeToString(response.getContentMd5())));
- Parameters:
data
- The data to write to the blob. Note that thisFlux
must be replayable if retries are enabled (the default). In other words, the Flux must produce the same data each time it is subscribed to.length
- The exact length of the data. It is important that this value match precisely the length of the data emitted by theFlux
.- Returns:
- A reactive response containing the information of the uploaded block blob.
-
upload
Creates a new block blob. By default, this method will not overwrite an existing blob. Updating an existing block blob overwrites any existing metadata on the blob. Partial updates are not supported with PutBlob; the content of the existing blob is overwritten with the new content. To perform a partial update of a block blob's, use PutBlock and PutBlockList. For more information, see the Azure Docs.Note that the data passed must be replayable if retries are enabled (the default). In other words, the
Flux
must produce the same data each time it is subscribed to.Code Samples
BinaryData.fromFlux(data, length, false) .flatMap(binaryData -> client.upload(binaryData)) .subscribe(response -> System.out.printf("Uploaded BlockBlob MD5 is %s%n", Base64.getEncoder().encodeToString(response.getContentMd5())));
- Parameters:
data
- The data to write to the block. Note that thisBinaryData
must have defined length and must be replayable if retries are enabled (the default), seeBinaryData.isReplayable()
.- Returns:
- A reactive response containing the information of the uploaded block blob.
-
upload
Creates a new block blob, or updates the content of an existing block blob. Updating an existing block blob overwrites any existing metadata on the blob. Partial updates are not supported with PutBlob; the content of the existing blob is overwritten with the new content. To perform a partial update of a block blob's, use PutBlock and PutBlockList. For more information, see the Azure Docs.Note that the data passed must be replayable if retries are enabled (the default). In other words, the
Flux
must produce the same data each time it is subscribed to.Code Samples
boolean overwrite = false; // Default behavior client.upload(data, length, overwrite).subscribe(response -> System.out.printf("Uploaded BlockBlob MD5 is %s%n", Base64.getEncoder().encodeToString(response.getContentMd5())));
- Parameters:
data
- The data to write to the blob. Note that thisFlux
must be replayable if retries are enabled (the default). In other words, the Flux must produce the same data each time it is subscribed to.length
- The exact length of the data. It is important that this value match precisely the length of the data emitted by theFlux
.overwrite
- Whether to overwrite, should data exist on the blob.- Returns:
- A reactive response containing the information of the uploaded block blob.
-
upload
Creates a new block blob, or updates the content of an existing block blob. Updating an existing block blob overwrites any existing metadata on the blob. Partial updates are not supported with PutBlob; the content of the existing blob is overwritten with the new content. To perform a partial update of a block blob's, use PutBlock and PutBlockList. For more information, see the Azure Docs.Note that the data passed must be replayable if retries are enabled (the default). In other words, the
Flux
must produce the same data each time it is subscribed to.Code Samples
boolean overwrite = false; // Default behavior BinaryData.fromFlux(data, length, false) .flatMap(binaryData -> client.upload(binaryData, overwrite)) .subscribe(response -> System.out.printf("Uploaded BlockBlob MD5 is %s%n", Base64.getEncoder().encodeToString(response.getContentMd5())));
- Parameters:
data
- The data to write to the block. Note that thisBinaryData
must have defined length and must be replayable if retries are enabled (the default), seeBinaryData.isReplayable()
.overwrite
- Whether to overwrite, should data exist on the blob.- Returns:
- A reactive response containing the information of the uploaded block blob.
-
uploadWithResponse
public Mono<com.azure.core.http.rest.Response<BlockBlobItem>> uploadWithResponse(Flux<ByteBuffer> data, long length, BlobHttpHeaders headers, Map<String, String> metadata, AccessTier tier, byte[] contentMd5, BlobRequestConditions requestConditions) Creates a new block blob, or updates the content of an existing block blob.Updating an existing block blob overwrites any existing metadata on the blob. Partial updates are not supported with PutBlob; the content of the existing blob is overwritten with the new content. To perform a partial update of a block blob's, use PutBlock and PutBlockList. For more information, see the Azure Docs.
Note that the data passed must be replayable if retries are enabled (the default). In other words, the
Flux
must produce the same data each time it is subscribed to.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"); byte[] md5 = MessageDigest.getInstance("MD5").digest("data".getBytes(StandardCharsets.UTF_8)); BlobRequestConditions requestConditions = new BlobRequestConditions() .setLeaseId(leaseId) .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); client.uploadWithResponse(data, length, headers, metadata, AccessTier.HOT, md5, requestConditions) .subscribe(response -> System.out.printf("Uploaded BlockBlob MD5 is %s%n", Base64.getEncoder().encodeToString(response.getValue().getContentMd5())));
- Parameters:
data
- The data to write to the blob. Note that thisFlux
must be replayable if retries are enabled (the default). In other words, the Flux must produce the same data each time it is subscribed to.length
- The exact length of the data. It is important that this value match precisely the length of the data emitted by theFlux
.headers
-BlobHttpHeaders
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.tier
-AccessTier
for the destination blob.contentMd5
- An MD5 hash of the blob content. This hash is used to verify the integrity of the blob during transport. When this header is specified, the storage service compares the hash of the content that has arrived with this header value. Note that this MD5 hash is not stored with the blob. If the two hashes do not match, the operation will fail.requestConditions
-BlobRequestConditions
- Returns:
- A reactive response containing the information of the uploaded block blob.
-
uploadWithResponse
public Mono<com.azure.core.http.rest.Response<BlockBlobItem>> uploadWithResponse(BlockBlobSimpleUploadOptions options) Creates a new block blob, or updates the content of an existing block blob.Updating an existing block blob overwrites any existing metadata on the blob. Partial updates are not supported with PutBlob; the content of the existing blob is overwritten with the new content. To perform a partial update of a block blob's, use PutBlock and PutBlockList. For more information, see the Azure Docs.
Note that the data passed must be replayable if retries are enabled (the default). In other words, the
Flux
must produce the same data each time it is subscribed to.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"); byte[] md5 = MessageDigest.getInstance("MD5").digest("data".getBytes(StandardCharsets.UTF_8)); BlobRequestConditions requestConditions = new BlobRequestConditions() .setLeaseId(leaseId) .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); client.uploadWithResponse(new BlockBlobSimpleUploadOptions(data, length).setHeaders(headers) .setMetadata(metadata).setTags(tags).setTier(AccessTier.HOT).setContentMd5(md5) .setRequestConditions(requestConditions)) .subscribe(response -> System.out.printf("Uploaded BlockBlob MD5 is %s%n", Base64.getEncoder().encodeToString(response.getValue().getContentMd5())));
- Parameters:
options
-BlockBlobSimpleUploadOptions
- Returns:
- A reactive response containing the information of the uploaded block blob.
-
uploadFromUrl
Creates a new block blob, or updates the content of an existing block blob.Updating an existing block blob overwrites any existing metadata on the blob. Partial updates are not supported with PutBlobFromUrl; the content of the existing blob is overwritten with the new content. For more information, see the Azure Docs.
Code Samples
client.uploadFromUrl(sourceUrl) .subscribe(response -> System.out.printf("Uploaded BlockBlob from URL, MD5 is %s%n", Base64.getEncoder().encodeToString(response.getContentMd5())));
- Parameters:
sourceUrl
- The source URL to upload from.- Returns:
- A reactive response containing the information of the uploaded block blob.
-
uploadFromUrl
Creates a new block blob, or updates the content of an existing block blob.Updating an existing block blob overwrites any existing metadata on the blob. Partial updates are not supported with PutBlobFromUrl; the content of the existing blob is overwritten with the new content. For more information, see the Azure Docs.
Code Samples
boolean overwrite = false; // Default behavior client.uploadFromUrl(sourceUrl, overwrite).subscribe(response -> System.out.printf("Uploaded BlockBlob from URL, MD5 is %s%n", Base64.getEncoder().encodeToString(response.getContentMd5())));
- Parameters:
sourceUrl
- The source URL to upload from.overwrite
- Whether to overwrite, should data exist on the blob.- Returns:
- A reactive response containing the information of the uploaded block blob.
-
uploadFromUrlWithResponse
public Mono<com.azure.core.http.rest.Response<BlockBlobItem>> uploadFromUrlWithResponse(BlobUploadFromUrlOptions options) Creates a new block blob, or updates the content of an existing block blob.Updating an existing block blob overwrites any existing metadata on the blob. Partial updates are not supported with PutBlobFromUrl; the content of the existing blob is overwritten with the new content. For more information, see the Azure Docs.
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"); byte[] md5 = MessageDigest.getInstance("MD5").digest("data".getBytes(StandardCharsets.UTF_8)); BlobRequestConditions requestConditions = new BlobRequestConditions() .setLeaseId(leaseId) .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); client.uploadFromUrlWithResponse(new BlobUploadFromUrlOptions(sourceUrl).setHeaders(headers) .setTags(tags).setTier(AccessTier.HOT).setContentMd5(md5) .setDestinationRequestConditions(requestConditions)) .subscribe(response -> System.out.printf("Uploaded BlockBlob from URL, MD5 is %s%n", Base64.getEncoder().encodeToString(response.getValue().getContentMd5())));
- Parameters:
options
-BlobUploadFromUrlOptions
- Returns:
- A reactive response containing the information of the uploaded block blob.
-
stageBlock
Uploads the specified block to the block blob's "staging area" to be later committed by a call to commitBlockList. For more information, see the Azure Docs.Note that the data passed must be replayable if retries are enabled (the default). In other words, the
Flux
must produce the same data each time it is subscribed to.- Parameters:
base64BlockId
- A Base64 encodedString
that specifies the ID for this block. Note that all block ids for a given blob must be the same length.data
- The data to write to the block. Note that thisFlux
must be replayable if retries are enabled (the default). In other words, theFlux
must produce the same data each time it is subscribed to.length
- The exact length of the data. It is important that this value match precisely the length of the data emitted by theFlux
.- Returns:
- A reactive response signalling completion.
Code Samples
client.stageBlock(base64BlockID, data, length) .subscribe( response -> System.out.println("Staging block completed"), error -> System.out.printf("Error when calling stage Block: %s", error));
-
stageBlock
Uploads the specified block to the block blob's "staging area" to be later committed by a call to commitBlockList. For more information, see the Azure Docs.Note that the data passed must be replayable if retries are enabled (the default), see
BinaryData.isReplayable()
.- Parameters:
base64BlockId
- A Base64 encodedString
that specifies the ID for this block. Note that all block ids for a given blob must be the same length.data
- The data to write to the block. Note that thisBinaryData
must have defined length and must be replayable if retries are enabled (the default), seeBinaryData.isReplayable()
.- Returns:
- A reactive response signalling completion.
Code Samples
BinaryData.fromFlux(data, length, false) .flatMap(binaryData -> client.stageBlock(base64BlockID, binaryData)) .subscribe( response -> System.out.println("Staging block completed"), error -> System.out.printf("Error when calling stage Block: %s", error));
-
stageBlockWithResponse
public Mono<com.azure.core.http.rest.Response<Void>> stageBlockWithResponse(String base64BlockId, Flux<ByteBuffer> data, long length, byte[] contentMd5, String leaseId) Uploads the specified block to the block blob's "staging area" to be later committed by a call to commitBlockList. For more information, see the Azure Docs.Note that the data passed must be replayable if retries are enabled (the default). In other words, the
Flux
must produce the same data each time it is subscribed to.Code Samples
client.stageBlockWithResponse(base64BlockID, data, length, md5, leaseId).subscribe(response -> System.out.printf("Staging block completed with status %d%n", response.getStatusCode()));
- Parameters:
base64BlockId
- A Base64 encodedString
that specifies the ID for this block. Note that all block ids for a given blob must be the same length.data
- The data to write to the block. Note that thisFlux
must be replayable if retries are enabled (the default). In other words, the Flux must produce the same data each time it is subscribed to.length
- The exact length of the data. It is important that this value match precisely the length of the data emitted by theFlux
.contentMd5
- An MD5 hash of the block content. This hash is used to verify the integrity of the block during transport. When this header is specified, the storage service compares the hash of the content that has arrived with this header value. Note that this MD5 hash is not stored with the blob. If the two hashes do not match, the operation will fail.leaseId
- The lease ID the active lease on the blob must match.- Returns:
- A reactive response signalling completion.
-
stageBlockWithResponse
public Mono<com.azure.core.http.rest.Response<Void>> stageBlockWithResponse(BlockBlobStageBlockOptions options) Uploads the specified block to the block blob's "staging area" to be later committed by a call to commitBlockList. For more information, see the Azure Docs.Note that the data passed must be replayable if retries are enabled (the default), see
BinaryData.isReplayable()
.Code Samples
BinaryData.fromFlux(data, length, false) .flatMap(binaryData -> client.stageBlockWithResponse( new BlockBlobStageBlockOptions(base64BlockID, binaryData) .setContentMd5(md5) .setLeaseId(leaseId))) .subscribe(response -> System.out.printf("Staging block completed with status %d%n", response.getStatusCode()));
- Parameters:
options
-BlockBlobStageBlockOptions
- Returns:
- A reactive response signalling completion.
-
stageBlockFromUrl
Creates a new block to be committed as part of a blob where the contents are read from a URL. For more information, see the Azure Docs.Code Samples
client.stageBlockFromUrl(base64BlockID, sourceUrl, new BlobRange(offset, count)) .subscribe( response -> System.out.println("Staging block completed"), error -> System.out.printf("Error when calling stage Block: %s", error));
- Parameters:
base64BlockId
- A Base64 encodedString
that specifies the ID for this block. Note that all block ids for a given blob must be the same length.sourceUrl
- The url to the blob that will be the source of the copy. A source blob in the same storage account can be authenticated via Shared Key. However, if the source is a blob in another account, the source blob must either be public or must be authenticated via a shared access signature. If the source blob is public, no authentication is required to perform the operation.sourceRange
-BlobRange
- Returns:
- A reactive response signalling completion.
-
stageBlockFromUrlWithResponse
public Mono<com.azure.core.http.rest.Response<Void>> stageBlockFromUrlWithResponse(String base64BlockId, String sourceUrl, BlobRange sourceRange, byte[] sourceContentMd5, String leaseId, BlobRequestConditions sourceRequestConditions) Creates a new block to be committed as part of a blob where the contents are read from a URL. For more information, see the Azure Docs.Code Samples
BlobRequestConditions sourceRequestConditions = new BlobRequestConditions() .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); client.stageBlockFromUrlWithResponse(base64BlockID, sourceUrl, new BlobRange(offset, count), null, leaseId, sourceRequestConditions).subscribe(response -> System.out.printf("Staging block from URL completed with status %d%n", response.getStatusCode()));
- Parameters:
base64BlockId
- A Base64 encodedString
that specifies the ID for this block. Note that all block ids for a given blob must be the same length.sourceUrl
- The url to the blob that will be the source of the copy. A source blob in the same storage account can be authenticated via Shared Key. However, if the source is a blob in another account, the source blob must either be public or must be authenticated via a shared access signature. If the source blob is public, no authentication is required to perform the operation.sourceRange
-BlobRange
sourceContentMd5
- An MD5 hash of the block content. This hash is used to verify the integrity of the block during transport. When this header is specified, the storage service compares the hash of the content that has arrived with this header value. Note that this MD5 hash is not stored with the blob. If the two hashes do not match, the operation will fail.leaseId
- The lease ID that the active lease on the blob must match.sourceRequestConditions
-BlobRequestConditions
- Returns:
- A reactive response signalling completion.
-
stageBlockFromUrlWithResponse
public Mono<com.azure.core.http.rest.Response<Void>> stageBlockFromUrlWithResponse(BlockBlobStageBlockFromUrlOptions options) Creates a new block to be committed as part of a blob where the contents are read from a URL. For more information, see the Azure Docs.Code Samples
BlobRequestConditions sourceRequestConditions = new BlobRequestConditions() .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); client.stageBlockFromUrlWithResponse(new BlockBlobStageBlockFromUrlOptions(base64BlockID, sourceUrl) .setSourceRange(new BlobRange(offset, count)).setLeaseId(leaseId) .setSourceRequestConditions(sourceRequestConditions)).subscribe(response -> System.out.printf("Staging block from URL completed with status %d%n", response.getStatusCode()));
- Parameters:
options
- parameters for the operation.- Returns:
- A reactive response signalling completion.
-
listBlocks
Returns the list of blocks that have been uploaded as part of a block blob using the specified block list filter. For more information, see the Azure Docs.Code Samples
client.listBlocks(BlockListType.ALL).subscribe(block -> { System.out.println("Committed Blocks:"); block.getCommittedBlocks().forEach(b -> System.out.printf("Name: %s, Size: %d", b.getName(), b.getSizeLong())); System.out.println("Uncommitted Blocks:"); block.getUncommittedBlocks().forEach(b -> System.out.printf("Name: %s, Size: %d", b.getName(), b.getSizeLong())); });
- Parameters:
listType
- Specifies which type of blocks to return.- Returns:
- A reactive response containing the list of blocks.
-
listBlocksWithResponse
public Mono<com.azure.core.http.rest.Response<BlockList>> listBlocksWithResponse(BlockListType listType, String leaseId) Returns the list of blocks that have been uploaded as part of a block blob using the specified block list filter. For more information, see the Azure Docs.Code Samples
client.listBlocksWithResponse(BlockListType.ALL, leaseId).subscribe(response -> { BlockList block = response.getValue(); System.out.println("Committed Blocks:"); block.getCommittedBlocks().forEach(b -> System.out.printf("Name: %s, Size: %d", b.getName(), b.getSizeLong())); System.out.println("Uncommitted Blocks:"); block.getUncommittedBlocks().forEach(b -> System.out.printf("Name: %s, Size: %d", b.getName(), b.getSizeLong())); });
- Parameters:
listType
- Specifies which type of blocks to return.leaseId
- The lease ID the active lease on the blob must match.- Returns:
- A reactive response containing the list of blocks.
-
listBlocksWithResponse
public Mono<com.azure.core.http.rest.Response<BlockList>> listBlocksWithResponse(BlockBlobListBlocksOptions options) Returns the list of blocks that have been uploaded as part of a block blob using the specified block list filter. For more information, see the Azure Docs.Code Samples
client.listBlocksWithResponse(new BlockBlobListBlocksOptions(BlockListType.ALL) .setLeaseId(leaseId) .setIfTagsMatch(tags)).subscribe(response -> { BlockList block = response.getValue(); System.out.println("Committed Blocks:"); block.getCommittedBlocks().forEach(b -> System.out.printf("Name: %s, Size: %d", b.getName(), b.getSizeLong())); System.out.println("Uncommitted Blocks:"); block.getUncommittedBlocks().forEach(b -> System.out.printf("Name: %s, Size: %d", b.getName(), b.getSizeLong())); });
- Parameters:
options
-BlockBlobListBlocksOptions
- Returns:
- A reactive response containing the list of blocks.
-
commitBlockList
Writes a blob by specifying the list of block IDs that are to make up the blob. In order to be written as part of a blob, a block must have been successfully written to the server in a prior stageBlock operation. You can call commitBlockList to update a blob by uploading only those blocks that have changed, then committing the new and existing blocks together. Any blocks not specified in the block list and permanently deleted. For more information, see the Azure Docs.Code Samples
client.commitBlockList(Collections.singletonList(base64BlockID)).subscribe(response -> System.out.printf("Committing block list completed. Last modified: %s%n", response.getLastModified()));
- Parameters:
base64BlockIds
- A list of base64 encodeString
s that specifies the block IDs to be committed.- Returns:
- A reactive response containing the information of the block blob.
-
commitBlockList
Writes a blob by specifying the list of block IDs that are to make up the blob. In order to be written as part of a blob, a block must have been successfully written to the server in a prior stageBlock operation. You can call commitBlockList to update a blob by uploading only those blocks that have changed, then committing the new and existing blocks together. Any blocks not specified in the block list and permanently deleted. For more information, see the Azure Docs.Code Samples
boolean overwrite = false; // Default behavior client.commitBlockList(Collections.singletonList(base64BlockID), overwrite).subscribe(response -> System.out.printf("Committing block list completed. Last modified: %s%n", response.getLastModified()));
- Parameters:
base64BlockIds
- A list of base64 encodeString
s that specifies the block IDs to be committed.overwrite
- Whether to overwrite, should data exist on the blob.- Returns:
- A reactive response containing the information of the block blob.
-
commitBlockListWithResponse
public Mono<com.azure.core.http.rest.Response<BlockBlobItem>> commitBlockListWithResponse(List<String> base64BlockIds, BlobHttpHeaders headers, Map<String, String> metadata, AccessTier tier, BlobRequestConditions requestConditions) Writes a blob by specifying the list of block IDs that are to make up the blob. In order to be written as part of a blob, a block must have been successfully written to the server in a prior stageBlock operation. You can call commitBlockList to update a blob by uploading only those blocks that have changed, then committing the new and existing blocks together. Any blocks not specified in the block list and permanently deleted. For more information, see the Azure Docs.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)); client.commitBlockListWithResponse(Collections.singletonList(base64BlockID), headers, metadata, AccessTier.HOT, requestConditions).subscribe(response -> System.out.printf("Committing block list completed with status %d%n", response.getStatusCode()));
- Parameters:
base64BlockIds
- A list of base64 encodeString
s that specifies the block IDs to be committed.headers
-BlobHttpHeaders
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.tier
-AccessTier
for the destination blob.requestConditions
-BlobRequestConditions
- Returns:
- A reactive response containing the information of the block blob.
-
commitBlockListWithResponse
public Mono<com.azure.core.http.rest.Response<BlockBlobItem>> commitBlockListWithResponse(BlockBlobCommitBlockListOptions options) Writes a blob by specifying the list of block IDs that are to make up the blob. In order to be written as part of a blob, a block must have been successfully written to the server in a prior stageBlock operation. You can call commitBlockList to update a blob by uploading only those blocks that have changed, then committing the new and existing blocks together. Any blocks not specified in the block list and permanently deleted. For more information, see the Azure Docs.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)); client.commitBlockListWithResponse(new BlockBlobCommitBlockListOptions(Collections.singletonList(base64BlockID)) .setHeaders(headers).setMetadata(metadata).setTags(tags).setTier(AccessTier.HOT) .setRequestConditions(requestConditions)) .subscribe(response -> System.out.printf("Committing block list completed with status %d%n", response.getStatusCode()));
- Parameters:
options
-BlockBlobCommitBlockListOptions
- Returns:
- A reactive response containing the information of the block blob.
-
MAX_STAGE_BLOCK_BYTES_LONG