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.
|
Response<AppendBlobItem> |
appendBlockFromUrlWithResponse(String sourceUrl,
BlobRange sourceRange,
byte[] sourceContentMd5,
AppendBlobRequestConditions destAccessConditions,
BlobRequestConditions sourceAccessConditions,
Duration timeout,
Context context)
Commits a new block of data from another blob to the end of this append blob.
|
Response<AppendBlobItem> |
appendBlockWithResponse(InputStream data,
long length,
byte[] contentMd5,
AppendBlobRequestConditions appendBlobRequestConditions,
Duration timeout,
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.
|
Response<AppendBlobItem> |
createWithResponse(BlobHttpHeaders headers,
Map<String,String> metadata,
BlobRequestConditions accessConditions,
Duration timeout,
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 accessConditions)
Creates and opens an output stream to write data to the append blob.
|
abortCopyFromUrl, abortCopyFromUrlWithResponse, beginCopy, beginCopy, copyFromUrl, copyFromUrlWithResponse, createSnapshot, createSnapshotWithResponse, delete, deleteWithResponse, download, downloadToFile, downloadToFileWithResponse, downloadWithResponse, exists, existsWithResponse, getAccountInfo, getAccountInfoWithResponse, getAccountName, getBlobName, getBlobUrl, getContainerName, getCustomerProvidedKey, getHttpPipeline, getProperties, getPropertiesWithResponse, getServiceVersion, getSnapshotClient, getSnapshotId, isSnapshot, openInputStream, openInputStream, setAccessTier, setAccessTierWithResponse, setHttpHeaders, setHttpHeadersWithResponse, setMetadata, setMetadataWithResponse, undelete, undeleteWithResponse
public static final int MAX_APPEND_BLOCK_BYTES
public static final int MAX_BLOCKS
public BlobOutputStream getBlobOutputStream()
BlobOutputStream
object used to write data to the blob.BlobStorageException
- If a storage service error occurred.public BlobOutputStream getBlobOutputStream(AppendBlobRequestConditions accessConditions)
accessConditions
- 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 Response<AppendBlobItem> createWithResponse(BlobHttpHeaders headers, Map<String,String> metadata, BlobRequestConditions accessConditions, Duration timeout, Context context)
Code Samples
BlobHttpHeaders
headers = newBlobHttpHeaders
() .setContentType("binary") .setContentLanguage("en-US");Map
<String
,String
> metadata =Collections
.singletonMap("metadata", "value");BlobRequestConditions
accessConditions = newBlobRequestConditions
() .setLeaseId(leaseId) .setIfUnmodifiedSince(OffsetDateTime
.now().minusDays(3));Context
context = newContext
("key", "value");System
.out.printf("Created AppendBlob at %s%n", client.createWithResponse(headers, metadata, accessConditions, timeout, context).getValue().getLastModified());
headers
- BlobHttpHeaders
metadata
- Metadata to associate with the blob.accessConditions
- 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 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.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 Response<AppendBlobItem> appendBlockWithResponse(InputStream data, long length, byte[] contentMd5, AppendBlobRequestConditions appendBlobRequestConditions, Duration timeout, 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
accessConditions = newAppendBlobRequestConditions
() .setAppendPosition(POSITION) .setMaxSize(maxSize);Context
context = newContext
("key", "value");System
.out.printf("AppendBlob has %d committed blocks%n", client.appendBlockWithResponse(data, length, md5, accessConditions, timeout, context) .getValue().getBlobCommittedBlockCount());
data
- The data to write to the blob. Note that this 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.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.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, newBlobRange
(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 Response<AppendBlobItem> appendBlockFromUrlWithResponse(String sourceUrl, BlobRange sourceRange, byte[] sourceContentMd5, AppendBlobRequestConditions destAccessConditions, BlobRequestConditions sourceAccessConditions, Duration timeout, Context context)
Code Samples
AppendBlobRequestConditions
appendBlobRequestConditions = newAppendBlobRequestConditions
() .setAppendPosition(POSITION) .setMaxSize(maxSize);BlobRequestConditions
modifiedAccessConditions = newBlobRequestConditions
() .setIfUnmodifiedSince(OffsetDateTime
.now().minusDays(3));Context
context = newContext
("key", "value");System
.out.printf("AppendBlob has %d committed blocks%n", client.appendBlockFromUrlWithResponse(sourceUrl, newBlobRange
(offset, count), null, appendBlobRequestConditions, modifiedAccessConditions, 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.destAccessConditions
- AppendBlobRequestConditions
sourceAccessConditions
- 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.Copyright © 2019 Microsoft Corporation. All rights reserved.