AppendBlobAsyncClient Class
- java.
lang. Object - com.
azure. storage. blob. specialized. BlobAsyncClientBase - com.
azure. storage. blob. specialized. AppendBlobAsyncClient
- com.
- com.
public final class AppendBlobAsyncClient
extends BlobAsyncClientBase
Client to an append blob. It may only be instantiated through a buildAppendBlobAsyncClient() or via the method 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 Type | Field and Description |
---|---|
static final int |
MAX_APPEND_BLOCK_BYTES
Deprecated Indicates the maximum number of bytes that can be sent in a call to append |
static final int |
MAX_BLOCKS
Deprecated
use getMaxBlocks().
Indicates the maximum number of blocks allowed in an append blob. |
Method Summary
Methods inherited from BlobAsyncClientBase
Methods inherited from java.lang.Object
Field Details
MAX_APPEND_BLOCK_BYTES
@Deprecated
public static final int MAX_APPEND_BLOCK_BYTES
Deprecated
Indicates the maximum number of bytes that can be sent in a call to appendBlock.
MAX_BLOCKS
@Deprecated
public static final int MAX_BLOCKS
Deprecated
Indicates the maximum number of blocks allowed in an append blob.
Method Details
appendBlock
public Mono
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. For service versions 2022-11-02 and later, the max block size is 100 MB. For previous versions, the max block size is 4 MB. For more information, see the Azure Docs.
Code Samples
client.appendBlock(data, length).subscribe(response ->
System.out.printf("AppendBlob has %d committed blocks%n", response.getBlobCommittedBlockCount()));
Parameters:
Flux
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.
Flux
.
Returns:
appendBlockFromUrl
public Mono
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:
Returns:
appendBlockFromUrlWithResponse
public Mono
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:
Returns:
appendBlockFromUrlWithResponse
public Mono
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:
Returns:
appendBlockWithResponse
public Mono
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. For service versions 2022-11-02 and later, the max block size is 100 MB. For previous versions, the max block size is 4 MB. For more information, see the Azure Docs.
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:
Flux
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.
Flux
.
Returns:
create
public Mono
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:
create
public Mono
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:
Returns:
createIfNotExists
public Mono
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:
createIfNotExistsWithResponse
public Mono
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:
Returns:
createWithResponse
public Mono
Creates a 0-length append blob. Call appendBlock to append data to an append blob.
To avoid overwriting, pass "*" to setIfNoneMatch(String ifNoneMatch).
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:
Returns:
createWithResponse
public Mono
Creates a 0-length append blob. Call appendBlock to append data to an append blob.
To avoid overwriting, pass "*" to setIfNoneMatch(String ifNoneMatch).
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:
Returns:
getCustomerProvidedKeyAsyncClient
public AppendBlobAsyncClient getCustomerProvidedKeyAsyncClient(CustomerProvidedKey customerProvidedKey)
Creates a new AppendBlobAsyncClient with the specified customerProvidedKey
.
Overrides:
AppendBlobAsyncClient.getCustomerProvidedKeyAsyncClient(CustomerProvidedKey customerProvidedKey)Parameters:
null
to use no customer provided key.
Returns:
customerProvidedKey
.getEncryptionScopeAsyncClient
public AppendBlobAsyncClient getEncryptionScopeAsyncClient(String encryptionScope)
Creates a new AppendBlobAsyncClient with the specified encryptionScope
.
Overrides:
AppendBlobAsyncClient.getEncryptionScopeAsyncClient(String encryptionScope)Parameters:
null
to use no encryption scope.
Returns:
encryptionScope
.getMaxAppendBlockBytes
public int getMaxAppendBlockBytes()
Get the max number of append block bytes based on service version being used. Service versions 2022-11-02 and above support uploading block bytes up to 100MB, all older service versions support up to 4MB.
Returns:
getMaxBlocks
public int getMaxBlocks()
Get the maximum number of blocks allowed in an append blob.
Returns:
seal
public Mono
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:
sealWithResponse
public Mono
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:
Returns: