Class AppendBlobAsyncClient
SpecializedBlobClientBuilder.buildAppendBlobAsyncClient()
or via the method
BlobAsyncClient.getAppendBlobAsyncClient()
. 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.
This client contains operations on a blob. Operations on a container are available on BlobContainerAsyncClient
, and operations on the service are available on BlobServiceAsyncClient
.
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 bytes that can be sent in a call to appendBlock.static final int
Indicates the maximum number of blocks allowed in an append blob.Fields inherited from class com.azure.storage.blob.specialized.BlobAsyncClientBase
accountName, azureBlobStorage, blobName, containerName, encryptionScope, serviceVersion
-
Method Summary
Modifier and TypeMethodDescriptionappendBlock
(Flux<ByteBuffer> data, long length) Commits a new block of data to the end of the existing append blob.appendBlockFromUrl
(String sourceUrl, BlobRange sourceRange) Commits a new block of data from another blob to the end of this append blob.Mono<com.azure.core.http.rest.Response<AppendBlobItem>>
Commits a new block of data from another blob to the end of this append blob.Mono<com.azure.core.http.rest.Response<AppendBlobItem>>
appendBlockFromUrlWithResponse
(String sourceUrl, BlobRange sourceRange, byte[] sourceContentMD5, AppendBlobRequestConditions destRequestConditions, BlobRequestConditions sourceRequestConditions) Commits a new block of data from another blob to the end of this append blob.Mono<com.azure.core.http.rest.Response<AppendBlobItem>>
appendBlockWithResponse
(Flux<ByteBuffer> data, long length, byte[] contentMd5, AppendBlobRequestConditions appendBlobRequestConditions) Commits a new block of data to the end of the existing append blob.create()
Creates a 0-length append blob.create
(boolean overwrite) Creates a 0-length append blob.Creates a 0-length append blob if it does not exist.Mono<com.azure.core.http.rest.Response<AppendBlobItem>>
Creates a 0-length append blob if it does not exist.Mono<com.azure.core.http.rest.Response<AppendBlobItem>>
createWithResponse
(BlobHttpHeaders headers, Map<String, String> metadata, BlobRequestConditions requestConditions) Creates a 0-length append blob.Mono<com.azure.core.http.rest.Response<AppendBlobItem>>
Creates a 0-length append blob.getCustomerProvidedKeyAsyncClient
(CustomerProvidedKey customerProvidedKey) Creates a newAppendBlobAsyncClient
with the specifiedcustomerProvidedKey
.getEncryptionScopeAsyncClient
(String encryptionScope) Creates a newAppendBlobAsyncClient
with the specifiedencryptionScope
.seal()
Seals an append blob, making it read only.sealWithResponse
(AppendBlobSealOptions options) Seals an append blob, making it read only.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_APPEND_BLOCK_BYTES
public static final int MAX_APPEND_BLOCK_BYTESIndicates the maximum number of bytes that can be sent in a call to appendBlock.- See Also:
-
MAX_BLOCKS
public static final int MAX_BLOCKSIndicates the maximum number of blocks allowed in an append blob.- See Also:
-
-
Method Details
-
getEncryptionScopeAsyncClient
Creates a newAppendBlobAsyncClient
with the specifiedencryptionScope
.- Overrides:
getEncryptionScopeAsyncClient
in classBlobAsyncClientBase
- Parameters:
encryptionScope
- the encryption scope for the blob, passnull
to use no encryption scope.- Returns:
- a
AppendBlobAsyncClient
with the specifiedencryptionScope
.
-
getCustomerProvidedKeyAsyncClient
public AppendBlobAsyncClient getCustomerProvidedKeyAsyncClient(CustomerProvidedKey customerProvidedKey) Creates a newAppendBlobAsyncClient
with the specifiedcustomerProvidedKey
.- Overrides:
getCustomerProvidedKeyAsyncClient
in classBlobAsyncClientBase
- Parameters:
customerProvidedKey
- theCustomerProvidedKey
for the blob, passnull
to use no customer provided key.- Returns:
- a
AppendBlobAsyncClient
with the specifiedcustomerProvidedKey
.
-
create
Creates a 0-length append blob. Call appendBlock to append data to an append blob. By default this method will not overwrite an existing blob.Code Samples
client.create().subscribe(response -> System.out.printf("Created AppendBlob at %s%n", response.getLastModified()));
- Returns:
- A
Mono
containing the information of the created appended blob.
-
create
Creates a 0-length append blob. Call appendBlock to append data to an append blob.Code Samples
boolean overwrite = false; // Default behavior client.create(overwrite).subscribe(response -> System.out.printf("Created AppendBlob at %s%n", response.getLastModified()));
- Parameters:
overwrite
- Whether to overwrite, should data exist on the blob.- Returns:
- A
Mono
containing the information of the created appended blob.
-
createWithResponse
public Mono<com.azure.core.http.rest.Response<AppendBlobItem>> createWithResponse(BlobHttpHeaders headers, Map<String, String> metadata, BlobRequestConditions requestConditions) Creates a 0-length append blob. Call appendBlock to append data to an append blob.To avoid overwriting, pass "*" to
BlobRequestConditions.setIfNoneMatch(String)
.Code Samples
BlobHttpHeaders headers = new BlobHttpHeaders() .setContentType("binary") .setContentLanguage("en-US"); Map<String, String> metadata = Collections.singletonMap("metadata", "value"); BlobRequestConditions requestConditions = new BlobRequestConditions().setLeaseId(leaseId) .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); client.createWithResponse(headers, metadata, requestConditions).subscribe(response -> System.out.printf("Created AppendBlob at %s%n", response.getValue().getLastModified()));
- Parameters:
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.requestConditions
-BlobRequestConditions
- Returns:
- A
Mono
containingResponse
whosevalue
contains the created appended blob.
-
createWithResponse
public Mono<com.azure.core.http.rest.Response<AppendBlobItem>> createWithResponse(AppendBlobCreateOptions options) Creates a 0-length append blob. Call appendBlock to append data to an append blob.To avoid overwriting, pass "*" to
BlobRequestConditions.setIfNoneMatch(String)
.Code Samples
BlobHttpHeaders headers = new BlobHttpHeaders() .setContentType("binary") .setContentLanguage("en-US"); 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.createWithResponse(new AppendBlobCreateOptions().setHeaders(headers).setMetadata(metadata) .setTags(tags).setRequestConditions(requestConditions)).subscribe(response -> System.out.printf("Created AppendBlob at %s%n", response.getValue().getLastModified()));
- Parameters:
options
-AppendBlobCreateOptions
- Returns:
- A
Mono
containingResponse
whosevalue
contains the created appended blob.
-
createIfNotExists
Creates a 0-length append blob if it does not exist. Call appendBlock to append data to an append blob.Code Samples
client.createIfNotExists().subscribe(response -> System.out.printf("Created AppendBlob at %s%n", response.getLastModified()));
- Returns:
- A reactive response
Mono
signaling completion.AppendBlobItem
contains the information of the created appended blob.
-
createIfNotExistsWithResponse
public Mono<com.azure.core.http.rest.Response<AppendBlobItem>> createIfNotExistsWithResponse(AppendBlobCreateOptions options) Creates a 0-length append blob if it does not exist. Call appendBlock to append data to an append blob.Code Samples
BlobHttpHeaders headers = new BlobHttpHeaders() .setContentType("binary") .setContentLanguage("en-US"); Map<String, String> metadata = Collections.singletonMap("metadata", "value"); Map<String, String> tags = Collections.singletonMap("tag", "value"); client.createIfNotExistsWithResponse(new AppendBlobCreateOptions().setHeaders(headers) .setMetadata(metadata).setTags(tags)).subscribe(response -> { if (response.getStatusCode() == 409) { System.out.println("Already exists."); } else { System.out.println("successfully created."); } });
- Parameters:
options
-AppendBlobCreateOptions
- Returns:
- A
Mono
containingResponse
signaling completion, whosevalue
contains aAppendBlobItem
containing information about the append blob. IfResponse
's status code is 201, a new page blob was successfully created. If status code is 409, an append blob already existed at this location.
-
appendBlock
Commits a new block of data to the end of the existing append blob.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.appendBlock(data, length).subscribe(response -> System.out.printf("AppendBlob has %d committed blocks%n", response.getBlobCommittedBlockCount()));
- 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:
Mono
containing the information of the append blob operation.
-
appendBlockWithResponse
public Mono<com.azure.core.http.rest.Response<AppendBlobItem>> appendBlockWithResponse(Flux<ByteBuffer> data, long length, byte[] contentMd5, AppendBlobRequestConditions appendBlobRequestConditions) Commits a new block of data to the end of the existing append blob.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
byte[] md5 = MessageDigest.getInstance("MD5").digest("data".getBytes(StandardCharsets.UTF_8)); AppendBlobRequestConditions requestConditions = new AppendBlobRequestConditions() .setAppendPosition(POSITION) .setMaxSize(maxSize); client.appendBlockWithResponse(data, length, md5, requestConditions).subscribe(response -> System.out.printf("AppendBlob has %d committed blocks%n", response.getValue().getBlobCommittedBlockCount()));
- 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
.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.appendBlobRequestConditions
-AppendBlobRequestConditions
- Returns:
- A
Mono
containingResponse
whosevalue
contains the append blob operation.
-
appendBlockFromUrl
Commits a new block of data from another blob to the end of this append blob.Code Samples
client.appendBlockFromUrl(sourceUrl, new BlobRange(offset, count)).subscribe(response -> System.out.printf("AppendBlob has %d committed blocks%n", response.getBlobCommittedBlockCount()));
- Parameters:
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
- The sourceBlobRange
to copy.- Returns:
Mono
containing the information of the append blob operation.
-
appendBlockFromUrlWithResponse
public Mono<com.azure.core.http.rest.Response<AppendBlobItem>> appendBlockFromUrlWithResponse(String sourceUrl, BlobRange sourceRange, byte[] sourceContentMD5, AppendBlobRequestConditions destRequestConditions, BlobRequestConditions sourceRequestConditions) Commits a new block of data from another blob to the end of this append blob.Code Samples
AppendBlobRequestConditions appendBlobRequestConditions = new AppendBlobRequestConditions() .setAppendPosition(POSITION) .setMaxSize(maxSize); BlobRequestConditions modifiedRequestConditions = new BlobRequestConditions() .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); client.appendBlockFromUrlWithResponse(sourceUrl, new BlobRange(offset, count), null, appendBlobRequestConditions, modifiedRequestConditions).subscribe(response -> System.out.printf("AppendBlob has %d committed blocks%n", response.getValue().getBlobCommittedBlockCount()));
- Parameters:
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 from the source blob. If specified, the service will calculate the MD5 of the received data and fail the request if it does not match the provided MD5.destRequestConditions
-AppendBlobRequestConditions
sourceRequestConditions
-BlobRequestConditions
- Returns:
- A
Mono
containingResponse
whosevalue
contains the append blob operation.
-
appendBlockFromUrlWithResponse
public Mono<com.azure.core.http.rest.Response<AppendBlobItem>> appendBlockFromUrlWithResponse(AppendBlobAppendBlockFromUrlOptions options) Commits a new block of data from another blob to the end of this append blob.Code Samples
AppendBlobRequestConditions appendBlobRequestConditions = new AppendBlobRequestConditions() .setAppendPosition(POSITION) .setMaxSize(maxSize); BlobRequestConditions modifiedRequestConditions = new BlobRequestConditions() .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); client.appendBlockFromUrlWithResponse(new AppendBlobAppendBlockFromUrlOptions(sourceUrl) .setSourceRange(new BlobRange(offset, count)) .setDestinationRequestConditions(appendBlobRequestConditions) .setSourceRequestConditions(modifiedRequestConditions)).subscribe(response -> System.out.printf("AppendBlob has %d committed blocks%n", response.getValue().getBlobCommittedBlockCount()));
- Parameters:
options
- Parameters for the operation.- Returns:
- A
Mono
containingResponse
whosevalue
contains the append blob operation.
-
seal
Seals an append blob, making it read only. Any subsequent appends will fail.Code Samples
client.seal().subscribe(response -> System.out.println("Sealed AppendBlob"));
- Returns:
- A reactive response signalling completion.
-
sealWithResponse
public Mono<com.azure.core.http.rest.Response<Void>> sealWithResponse(AppendBlobSealOptions options) Seals an append blob, making it read only. Any subsequent appends will fail.Code Samples
AppendBlobRequestConditions requestConditions = new AppendBlobRequestConditions().setLeaseId(leaseId) .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); client.sealWithResponse(new AppendBlobSealOptions().setRequestConditions(requestConditions)) .subscribe(response -> System.out.println("Sealed AppendBlob"));
- Parameters:
options
-AppendBlobSealOptions
- Returns:
- A reactive response signalling completion.
-