Class AppendBlobClient
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.
-
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. -
Method Summary
Modifier and TypeMethodDescriptionappendBlock
(InputStream 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.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.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.com.azure.core.http.rest.Response<AppendBlobItem>
createIfNotExistsWithResponse
(AppendBlobCreateOptions options, Duration timeout, com.azure.core.util.Context context) Creates a 0-length append blob if it does not exist.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.com.azure.core.http.rest.Response<AppendBlobItem>
createWithResponse
(AppendBlobCreateOptions options, Duration timeout, com.azure.core.util.Context context) Creates a 0-length append blob.Creates and opens an output stream to write data to the append blob.getBlobOutputStream
(boolean overwrite) Creates and opens an output stream to write data to the append blob.getBlobOutputStream
(AppendBlobRequestConditions requestConditions) Creates and opens an output stream to write data to the append blob.getCustomerProvidedKeyClient
(CustomerProvidedKey customerProvidedKey) Creates a newAppendBlobClient
with the specifiedcustomerProvidedKey
.getEncryptionScopeClient
(String encryptionScope) Creates a newAppendBlobClient
with the specifiedencryptionScope
.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.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, 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, openInputStream, openQueryInputStream, openQueryInputStreamWithResponse, 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
-
getEncryptionScopeClient
Creates a newAppendBlobClient
with the specifiedencryptionScope
.- Overrides:
getEncryptionScopeClient
in classBlobClientBase
- Parameters:
encryptionScope
- the encryption scope for the blob, passnull
to use no encryption scope.- Returns:
- a
AppendBlobClient
with the specifiedencryptionScope
.
-
getCustomerProvidedKeyClient
Creates a newAppendBlobClient
with the specifiedcustomerProvidedKey
.- Overrides:
getCustomerProvidedKeyClient
in classBlobClientBase
- Parameters:
customerProvidedKey
- theCustomerProvidedKey
for the blob, passnull
to use no customer provided key.- Returns:
- a
AppendBlobClient
with the specifiedcustomerProvidedKey
.
-
getBlobOutputStream
Creates and opens an output stream to write data to the append blob. If the blob already exists on the service, new data will get appended to the existing blob.- Returns:
- A
BlobOutputStream
object used to write data to the blob. - Throws:
BlobStorageException
- If a storage service error occurred.
-
getBlobOutputStream
Creates and opens an output stream to write data to the append blob. If overwrite is specifiedtrue
, the existing blob will be deleted and recreated, should data exist on the blob. If overwrite is specifiedfalse
, new data will get appended to the existing blob.- Parameters:
overwrite
- Whether an existing blob should be deleted and recreated, should data exist on the blob.- Returns:
- A
BlobOutputStream
object used to write data to the blob. - Throws:
BlobStorageException
- If a storage service error occurred.
-
getBlobOutputStream
Creates and opens an output stream to write data to the append blob.- Parameters:
requestConditions
- ABlobRequestConditions
object that represents the access conditions for the blob.- Returns:
- A
BlobOutputStream
object used to write data to the blob. - Throws:
BlobStorageException
- If a storage service error occurred.
-
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
System.out.printf("Created AppendBlob at %s%n", client.create().getLastModified());
- Returns:
- 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 value System.out.printf("Created AppendBlob at %s%n", client.create(overwrite).getLastModified());
- Parameters:
overwrite
- Whether or not to overwrite, should data exist on the blob.- Returns:
- The information of the created appended blob.
-
createWithResponse
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) 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)); Context context = new Context("key", "value"); System.out.printf("Created AppendBlob at %s%n", client.createWithResponse(headers, metadata, requestConditions, timeout, context).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
timeout
- An optional timeout value beyond which aRuntimeException
will be raised.context
- Additional context that is passed through the Http pipeline during the service call.- Returns:
- A
Response
whosevalue
contains the created appended blob.
-
createWithResponse
public com.azure.core.http.rest.Response<AppendBlobItem> createWithResponse(AppendBlobCreateOptions options, Duration timeout, com.azure.core.util.Context context) 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("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());
- Parameters:
options
-AppendBlobCreateOptions
timeout
- An optional timeout value beyond which aRuntimeException
will be raised.context
- Additional context that is passed through the Http pipeline during the service call.- Returns:
- A
Response
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(); System.out.println("Created AppendBlob");
- Returns:
AppendBlobItem
containing information of the created appended blob.
-
createIfNotExistsWithResponse
public com.azure.core.http.rest.Response<AppendBlobItem> createIfNotExistsWithResponse(AppendBlobCreateOptions options, Duration timeout, com.azure.core.util.Context context) 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("tags", "value"); Context context = new Context("key", "value"); Response<AppendBlobItem> response = client.createIfNotExistsWithResponse(new AppendBlobCreateOptions() .setHeaders(headers).setMetadata(metadata).setTags(tags), timeout, context); if (response.getStatusCode() == 409) { System.out.println("Already existed."); } else { System.out.printf("Create completed with status %d%n", response.getStatusCode()); }
- Parameters:
options
-AppendBlobCreateOptions
timeout
- An optional timeout value beyond which aRuntimeException
will be raised.context
- Additional context that is passed through the Http pipeline during the service call.- Returns:
- A reactive response
Response
signaling completion, whosevalue
contains theAppendBlobItem
containing information about the append blob. IfResponse
's status code is 201, a new append 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
System.out.printf("AppendBlob has %d committed blocks%n", client.appendBlock(data, length).getBlobCommittedBlockCount());
- 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 usinggetBlobOutputStream()
and writing to the returned OutputStream. Alternatively, consider wrapping your data source in aBufferedInputStream
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 theFlux
.- Returns:
- The information of the append blob operation.
-
appendBlockWithResponse
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) 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); 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());
- 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 usinggetBlobOutputStream()
and writing to the returned OutputStream. Alternatively, consider wrapping your data source in aBufferedInputStream
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 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
timeout
- An optional timeout value beyond which aRuntimeException
will be raised.context
- Additional context that is passed through the Http pipeline during the service call.- Returns:
- A
Response
whosevalue
contains the append blob operation. - Throws:
com.azure.core.exception.UnexpectedLengthException
- when the length of data does not match the inputlength
.NullPointerException
- if the input data is null.
-
appendBlockFromUrl
Commits a new block of data from another blob to the end of this append blob.Code Samples
System.out.printf("AppendBlob has %d committed blocks%n", client.appendBlockFromUrl(sourceUrl, new BlobRange(offset, count)).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:
- The information of the append blob operation.
-
appendBlockFromUrlWithResponse
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) 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)); 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());
- 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
timeout
- An optional timeout value beyond which aRuntimeException
will be raised.context
- Additional context that is passed through the Http pipeline during the service call.- Returns:
- The information of the append blob operation.
-
appendBlockFromUrlWithResponse
public 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.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());
- Parameters:
options
- options for the operationtimeout
- An optional timeout value beyond which aRuntimeException
will be raised.context
- Additional context that is passed through the Http pipeline during the service call.- Returns:
- The information of the append blob operation.
-
seal
public void seal()Seals an append blob, making it read only. Any subsequent appends will fail.Code Samples
client.seal(); System.out.println("Sealed AppendBlob");
-
sealWithResponse
public 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. Any subsequent appends will fail.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");
- Parameters:
options
-AppendBlobSealOptions
timeout
- An optional timeout value beyond which aRuntimeException
will be raised.context
- Additional context that is passed through the Http pipeline during the service call.- Returns:
- A reactive response signalling completion.
-