public final class AppendBlobClient extends BlobClientBase
SpecializedBlobClientBuilder
or via the
method BlobClient.getAppendBlobClient()
. 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 BlobContainerClient
,
and operations on the service are available on BlobServiceClient
.
Please refer to the Azure Docs for more information.
Modifier and Type | Field and Description |
---|---|
static int |
MAX_APPEND_BLOCK_BYTES
Indicates the maximum number of bytes that can be sent in a call to appendBlock.
|
static int |
MAX_BLOCKS
Indicates the maximum number of blocks allowed in an append blob.
|
Modifier and Type | Method and Description |
---|---|
AppendBlobItem |
appendBlock(InputStream data,
long length)
Commits a new block of data to the end of the existing append blob.
|
AppendBlobItem |
appendBlockFromUrl(String sourceUrl,
BlobRange sourceRange)
Commits a new block of data from another blob to the end of this append blob.
|
com.azure.core.http.rest.Response<AppendBlobItem> |
appendBlockFromUrlWithResponse(AppendBlobAppendBlockFromUrlOptions options,
Duration timeout,
com.azure.core.util.Context context)
Commits a new block of data from another blob to the end of this append blob.
|
com.azure.core.http.rest.Response<AppendBlobItem> |
appendBlockFromUrlWithResponse(String sourceUrl,
BlobRange sourceRange,
byte[] sourceContentMd5,
AppendBlobRequestConditions destRequestConditions,
BlobRequestConditions sourceRequestConditions,
Duration timeout,
com.azure.core.util.Context context)
Commits a new block of data from another blob to the end of this append blob.
|
com.azure.core.http.rest.Response<AppendBlobItem> |
appendBlockWithResponse(InputStream data,
long length,
byte[] contentMd5,
AppendBlobRequestConditions appendBlobRequestConditions,
Duration timeout,
com.azure.core.util.Context context)
Commits a new block of data to the end of the existing append blob.
|
AppendBlobItem |
create()
Creates a 0-length append blob.
|
AppendBlobItem |
create(boolean overwrite)
Creates a 0-length append blob.
|
com.azure.core.http.rest.Response<AppendBlobItem> |
createWithResponse(AppendBlobCreateOptions options,
Duration timeout,
com.azure.core.util.Context context)
Creates a 0-length append blob.
|
com.azure.core.http.rest.Response<AppendBlobItem> |
createWithResponse(BlobHttpHeaders headers,
Map<String,String> metadata,
BlobRequestConditions requestConditions,
Duration timeout,
com.azure.core.util.Context context)
Creates a 0-length append blob.
|
BlobOutputStream |
getBlobOutputStream()
Creates and opens an output stream to write data to the append blob.
|
BlobOutputStream |
getBlobOutputStream(AppendBlobRequestConditions requestConditions)
Creates and opens an output stream to write data to the append blob.
|
AppendBlobClient |
getCustomerProvidedKeyClient(CustomerProvidedKey customerProvidedKey)
Creates a new
AppendBlobClient with the specified customerProvidedKey . |
AppendBlobClient |
getEncryptionScopeClient(String encryptionScope)
Creates a new
AppendBlobClient with the specified encryptionScope . |
void |
seal()
Seals an append blob, making it read only.
|
com.azure.core.http.rest.Response<Void> |
sealWithResponse(AppendBlobSealOptions options,
Duration timeout,
com.azure.core.util.Context context)
Seals an append blob, making it read only.
|
abortCopyFromUrl, abortCopyFromUrlWithResponse, beginCopy, beginCopy, beginCopy, copyFromUrl, copyFromUrlWithResponse, copyFromUrlWithResponse, createSnapshot, createSnapshotWithResponse, delete, 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, getContainerClient, getContainerName, getCustomerProvidedKey, getHttpPipeline, getProperties, getPropertiesWithResponse, getServiceVersion, getSnapshotClient, getSnapshotId, getTags, getTagsWithResponse, getVersionClient, getVersionId, isSnapshot, openInputStream, openInputStream, openInputStream, openQueryInputStream, openQueryInputStreamWithResponse, query, queryWithResponse, setAccessTier, setAccessTierWithResponse, setAccessTierWithResponse, setHttpHeaders, setHttpHeadersWithResponse, setImmutabilityPolicy, setImmutabilityPolicyWithResponse, setLegalHold, setLegalHoldWithResponse, setMetadata, setMetadataWithResponse, setTags, setTagsWithResponse, undelete, undeleteWithResponse
public static final int MAX_APPEND_BLOCK_BYTES
public static final int MAX_BLOCKS
public AppendBlobClient getEncryptionScopeClient(String encryptionScope)
AppendBlobClient
with the specified encryptionScope
.getEncryptionScopeClient
in class BlobClientBase
encryptionScope
- the encryption scope for the blob, pass null
to use no encryption scope.AppendBlobClient
with the specified encryptionScope
.public AppendBlobClient getCustomerProvidedKeyClient(CustomerProvidedKey customerProvidedKey)
AppendBlobClient
with the specified customerProvidedKey
.getCustomerProvidedKeyClient
in class BlobClientBase
customerProvidedKey
- the CustomerProvidedKey
for the blob,
pass null
to use no customer provided key.AppendBlobClient
with the specified customerProvidedKey
.public BlobOutputStream getBlobOutputStream()
BlobOutputStream
object used to write data to the blob.BlobStorageException
- If a storage service error occurred.public BlobOutputStream getBlobOutputStream(AppendBlobRequestConditions requestConditions)
requestConditions
- A BlobRequestConditions
object that represents the access conditions for the
blob.BlobOutputStream
object used to write data to the blob.BlobStorageException
- If a storage service error occurred.public AppendBlobItem create()
Code Samples
System.out.printf("Created AppendBlob at %s%n", client.create().getLastModified());
public AppendBlobItem create(boolean overwrite)
Code Samples
boolean overwrite = false; // Default value System.out.printf("Created AppendBlob at %s%n", client.create(overwrite).getLastModified());
overwrite
- Whether or not to overwrite, should data exist on the blob.public com.azure.core.http.rest.Response<AppendBlobItem> createWithResponse(BlobHttpHeaders headers, Map<String,String> metadata, BlobRequestConditions requestConditions, Duration timeout, com.azure.core.util.Context context)
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)); Context context = new Context("key", "value"); System.out.printf("Created AppendBlob at %s%n", client.createWithResponse(headers, metadata, requestConditions, timeout, context).getValue() .getLastModified());
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
timeout
- An optional timeout value beyond which a RuntimeException
will be raised.context
- Additional context that is passed through the Http pipeline during the service call.Response
whose value
contains the created appended blob.public com.azure.core.http.rest.Response<AppendBlobItem> createWithResponse(AppendBlobCreateOptions options, Duration timeout, com.azure.core.util.Context context)
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("tags", "value"); BlobRequestConditions requestConditions = new BlobRequestConditions() .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); Context context = new Context("key", "value"); System.out.printf("Created AppendBlob at %s%n", client.createWithResponse(new AppendBlobCreateOptions().setHeaders(headers).setMetadata(metadata) .setTags(tags).setRequestConditions(requestConditions), timeout, context).getValue() .getLastModified());
options
- AppendBlobCreateOptions
timeout
- An optional timeout value beyond which a RuntimeException
will be raised.context
- Additional context that is passed through the Http pipeline during the service call.Response
whose value
contains the created appended blob.public AppendBlobItem appendBlock(InputStream data, long length)
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
System.out.printf("AppendBlob has %d committed blocks%n", client.appendBlock(data, length).getBlobCommittedBlockCount());
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 using AppendBlobClient.getBlobOutputStream()
and writing to the returned OutputStream.
Alternatively, consider wrapping your data source in a BufferedInputStream
to add mark support.length
- The exact length of the data. It is important that this value match precisely the length of the
data emitted by the Flux
.public com.azure.core.http.rest.Response<AppendBlobItem> appendBlockWithResponse(InputStream data, long length, byte[] contentMd5, AppendBlobRequestConditions appendBlobRequestConditions, Duration timeout, com.azure.core.util.Context context)
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); Context context = new Context("key", "value"); System.out.printf("AppendBlob has %d committed blocks%n", client.appendBlockWithResponse(data, length, md5, requestConditions, timeout, context) .getValue().getBlobCommittedBlockCount());
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 using AppendBlobClient.getBlobOutputStream()
and writing to the returned OutputStream.
Alternatively, consider wrapping your data source in a BufferedInputStream
to add mark support.length
- The exact length of the data. It is important that this value match precisely the length of the
data emitted by the Flux
.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
timeout
- An optional timeout value beyond which a RuntimeException
will be raised.context
- Additional context that is passed through the Http pipeline during the service call.Response
whose value
contains the append blob operation.com.azure.core.exception.UnexpectedLengthException
- when the length of data does not match the input length
.NullPointerException
- if the input data is null.public AppendBlobItem appendBlockFromUrl(String sourceUrl, BlobRange sourceRange)
Code Samples
System.out.printf("AppendBlob has %d committed blocks%n", client.appendBlockFromUrl(sourceUrl, new BlobRange(offset, count)).getBlobCommittedBlockCount());
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 source BlobRange
to copy.public com.azure.core.http.rest.Response<AppendBlobItem> appendBlockFromUrlWithResponse(String sourceUrl, BlobRange sourceRange, byte[] sourceContentMd5, AppendBlobRequestConditions destRequestConditions, BlobRequestConditions sourceRequestConditions, Duration timeout, com.azure.core.util.Context context)
Code Samples
AppendBlobRequestConditions appendBlobRequestConditions = new AppendBlobRequestConditions() .setAppendPosition(POSITION) .setMaxSize(maxSize); BlobRequestConditions modifiedRequestConditions = new BlobRequestConditions() .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); Context context = new Context("key", "value"); System.out.printf("AppendBlob has %d committed blocks%n", client.appendBlockFromUrlWithResponse(sourceUrl, new BlobRange(offset, count), null, appendBlobRequestConditions, modifiedRequestConditions, timeout, context).getValue().getBlobCommittedBlockCount());
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
timeout
- An optional timeout value beyond which a RuntimeException
will be raised.context
- Additional context that is passed through the Http pipeline during the service call.public com.azure.core.http.rest.Response<AppendBlobItem> appendBlockFromUrlWithResponse(AppendBlobAppendBlockFromUrlOptions options, Duration timeout, com.azure.core.util.Context context)
Code Samples
AppendBlobRequestConditions appendBlobRequestConditions = new AppendBlobRequestConditions() .setAppendPosition(POSITION) .setMaxSize(maxSize); BlobRequestConditions modifiedRequestConditions = new BlobRequestConditions() .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); Context context = new Context("key", "value"); System.out.printf("AppendBlob has %d committed blocks%n", client.appendBlockFromUrlWithResponse(new AppendBlobAppendBlockFromUrlOptions(sourceUrl) .setSourceRange(new BlobRange(offset, count)) .setDestinationRequestConditions(appendBlobRequestConditions) .setSourceRequestConditions(modifiedRequestConditions), timeout, context).getValue().getBlobCommittedBlockCount());
options
- options for the operationtimeout
- An optional timeout value beyond which a RuntimeException
will be raised.context
- Additional context that is passed through the Http pipeline during the service call.public void seal()
Code Samples
client.seal(); System.out.println("Sealed AppendBlob");
public com.azure.core.http.rest.Response<Void> sealWithResponse(AppendBlobSealOptions options, Duration timeout, com.azure.core.util.Context context)
Code Samples
AppendBlobRequestConditions requestConditions = new AppendBlobRequestConditions().setLeaseId(leaseId) .setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)); Context context = new Context("key", "value"); client.sealWithResponse(new AppendBlobSealOptions().setRequestConditions(requestConditions), timeout, context); System.out.println("Sealed AppendBlob");
options
- AppendBlobSealOptions
timeout
- An optional timeout value beyond which a RuntimeException
will be raised.context
- Additional context that is passed through the Http pipeline during the service call.Copyright © 2021 Microsoft Corporation. All rights reserved.