CloudAppendBlob Class
- java.
lang. Object - ListBlobItem
- CloudBlob
- com.
microsoft. azure. storage. blob. CloudAppendBlob
- com.
public class CloudAppendBlob extends CloudBlob
Represents a Microsoft Azure Append Blob.
Constructor Summary
Constructor | Description |
---|---|
CloudAppendBlob(final CloudAppendBlob otherBlob) |
Creates an instance of the class by copying values from another append blob. |
CloudAppendBlob(final StorageUri blobAbsoluteUri) |
Creates an instance of the class using the specified absolute URI and storage service client. |
CloudAppendBlob(final StorageUri blobAbsoluteUri, final StorageCredentials credentials) |
Creates an instance of the class using the specified absolute StorageUri and credentials. |
CloudAppendBlob(final StorageUri blobAbsoluteUri, final String snapshotID, final StorageCredentials credentials) |
Creates an instance of the class using the specified absolute StorageUri, snapshot ID, and credentials. |
CloudAppendBlob(final URI blobAbsoluteUri) |
Creates an instance of the class using the specified absolute URI and storage service client. |
CloudAppendBlob(final URI blobAbsoluteUri, final StorageCredentials credentials) |
Creates an instance of the class using the specified absolute URI and credentials. |
CloudAppendBlob(final URI blobAbsoluteUri, final String snapshotID, final StorageCredentials credentials) |
Creates an instance of the class using the specified absolute URI, snapshot ID, and credentials. |
CloudAppendBlob(String blobName, String snapshotID, CloudBlobContainer container) |
Creates an instance of the class using the specified type, name, snapshot ID, and container. |
Method Summary
Modifier and Type | Method and Description |
---|---|
void |
append(InputStream sourceStream, final long length)
Appends a stream to an append blob. This API should be used strictly in a single writer scenario because the API internally uses the append-offset conditional header to avoid duplicate blocks which does not work in a multiple writer scenario. If you are doing writes in a single writer scenario, please look at setAbsorbConditionalErrorsOnRetry(final Boolean absorbConditionalErrorsOnRetry) and see if setting this flag to is acceptable for you. |
void |
append(InputStream sourceStream, final long length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext)
Appends a stream to an append blob. This API should be used strictly in a single writer scenario because the API internally uses the append-offset conditional header to avoid duplicate blocks which does not work in a multiple writer scenario. If you are doing writes in a single writer scenario, please look at setAbsorbConditionalErrorsOnRetry(final Boolean absorbConditionalErrorsOnRetry) and see if setting this flag to is acceptable for you. |
Long |
appendBlock(final InputStream sourceStream, final long length)
Commits a new block of data to the end of the blob. |
Long |
appendBlock(final InputStream sourceStream, final long length, final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext)
Commits a new block of data to the end of the blob. |
Long |
appendBlockFromURI(final URI copySource, final Long offset, final Long length)
Appends a block, using the specified source URL. |
Long |
appendBlockFromURI(final URI copySource, final Long offset, final Long length, String md5, final AccessCondition accessCondition, final AccessCondition sourceAccessCondition, BlobRequestOptions options, OperationContext opContext)
Appends a block, using the specified source URL. |
void |
appendFromByteArray(final byte[] buffer, final int offset, final int length)
Appends the contents of a byte array to an append blob.This API should be used strictly in a single writer scenario because the API internally uses the append-offset conditional header to avoid duplicate blocks which does not work in a multiple writer scenario. If you are doing writes in a single writer scenario, please look at setAbsorbConditionalErrorsOnRetry(final Boolean absorbConditionalErrorsOnRetry) and see if setting this flag to is acceptable for you. |
void |
appendFromByteArray(final byte[] buffer, final int offset, final int length, final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext)
Appends the contents of a byte array to an append blob.This API should be used strictly in a single writer scenario because the API internally uses the append-offset conditional header to avoid duplicate blocks which does not work in a multiple writer scenario. If you are doing writes in a single writer scenario, please look at setAbsorbConditionalErrorsOnRetry(final Boolean absorbConditionalErrorsOnRetry) and see if setting this flag to is acceptable for you. |
void |
appendFromFile(final String path)
Appends a file to an append blob. This API should be used strictly in a single writer scenario because the API internally uses the append-offset conditional header to avoid duplicate blocks which does not work in a multiple writer scenario. If you are doing writes in a single writer scenario, please look at setAbsorbConditionalErrorsOnRetry(final Boolean absorbConditionalErrorsOnRetry) and see if setting this flag to is acceptable for you. |
void |
appendFromFile(final String path, final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext)
Appends a file to an append blob. This API should be used strictly in a single writer scenario because the API internally uses the append-offset conditional header to avoid duplicate blocks which does not work in a multiple writer scenario. If you are doing writes in a single writer scenario, please look at setAbsorbConditionalErrorsOnRetry(final Boolean absorbConditionalErrorsOnRetry) and see if setting this flag to is acceptable for you. |
void |
appendText(final String content)
Appends a string of text to an append blob using the platform's default encoding. This API should be used strictly in a single writer scenario because the API internally uses the append-offset conditional header to avoid duplicate blocks which does not work in a multiple writer scenario. If you are doing writes in a single writer scenario, please look at setAbsorbConditionalErrorsOnRetry(final Boolean absorbConditionalErrorsOnRetry) and see if setting this flag to is acceptable for you. |
void |
appendText(final String content, final String charsetName, final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext)
Appends a string of text to an append blob using the specified encoding. This API should be used strictly in a single writer scenario because the API internally uses the append-offset conditional header to avoid duplicate blocks which does not work in a multiple writer scenario. If you are doing writes in a single writer scenario, please look at setAbsorbConditionalErrorsOnRetry(final Boolean absorbConditionalErrorsOnRetry) and see if setting this flag to is acceptable for you. |
void |
createOrReplace()
Creates an empty append blob. If the blob already exists, this will replace it. To avoid overwriting and instead throw an error, please use the createOrReplace(final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext) overload with the appropriate AccessCondition. |
void |
createOrReplace(final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext)
Creates an append blob using the specified request options and operation context. If the blob already exists, this will replace it. To avoid overwriting and instead throw an error, please pass in an AccessCondition generated using generateIfNotExistsCondition(). |
Blob |
openWriteExisting()
Opens an output stream object to write data to the append blob. The append blob must already exist and will be appended to. If you are doing writes in a single writer scenario, please look at setAbsorbConditionalErrorsOnRetry(final Boolean absorbConditionalErrorsOnRetry) and see if setting this flag to is acceptable for you. |
Blob |
openWriteExisting(AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext)
Opens an output stream object to write data to the append blob, using the specified lease ID, request options and operation context. The append blob must already exist and will be appended to. If you are doing writes in a single writer scenario, please look at setAbsorbConditionalErrorsOnRetry(final Boolean absorbConditionalErrorsOnRetry) and see if setting this flag to is acceptable for you. |
Blob |
openWriteNew()
Opens an output stream object to write data to the append blob. The append blob does not need to yet exist. If the blob already exists, this will replace it. To avoid overwriting and instead throw an error, please use the openWriteNew(AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext) overload with the appropriate AccessCondition. If you are doing writes in a single writer scenario, please look at setAbsorbConditionalErrorsOnRetry(final Boolean absorbConditionalErrorsOnRetry) and see if setting this flag to is acceptable for you. |
Blob |
openWriteNew(AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext)
Opens an output stream object to write data to the append blob, using the specified lease ID, request options and operation context. The append blob does not need to yet exist. If the blob already exists, this will replace it. To avoid overwriting and instead throw an error, please pass in an AccessCondition generated using generateIfNotExistsCondition(). If you are doing writes in a single writer scenario, please look at setAbsorbConditionalErrorsOnRetry(final Boolean absorbConditionalErrorsOnRetry) and see if setting this flag to is acceptable for you. |
void |
setStreamWriteSizeInBytes(final int streamWriteSizeInBytes)
Sets the number of bytes to buffer when writing to a BlobOutputStream. |
final String |
startCopy(final CloudAppendBlob sourceBlob)
Requests the service to start copying a append blob's contents, properties, and metadata to a new append blob. |
final String |
startCopy(final CloudAppendBlob sourceBlob, final AccessCondition sourceAccessCondition, final AccessCondition destinationAccessCondition, BlobRequestOptions options, OperationContext opContext)
Requests the service to start copying a append blob's contents, properties, and metadata to a new append blob, using the specified access conditions, lease ID, request options, and operation context. |
void |
upload(final InputStream sourceStream, final long length)
Uploads the source stream data to the append blob. If the blob already exists on the service, it will be overwritten. If you want to append data to an already existing blob, please see appendBlock(final InputStream sourceStream, final long length). If you are doing writes in a single writer scenario, please look at setAbsorbConditionalErrorsOnRetry(final Boolean absorbConditionalErrorsOnRetry) and see if setting this flag to is acceptable for you. |
void |
upload(final InputStream sourceStream, final long length, final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext)
Uploads the source stream data to the append blob using the specified lease ID, request options, and operation context. If the blob already exists on the service, it will be overwritten. If you want to append data to an already existing blob, please see appendBlock(final InputStream sourceStream, final long length). If you are doing writes in a single writer scenario, please look at setAbsorbConditionalErrorsOnRetry(final Boolean absorbConditionalErrorsOnRetry) and see if setting this flag to is acceptable for you. |
Inherited Members
Constructor Details
CloudAppendBlob
public CloudAppendBlob(final CloudAppendBlob otherBlob)
Creates an instance of the class by copying values from another append blob.
Parameters:
CloudAppendBlob
object which represents the append blob to copy.
CloudAppendBlob
public CloudAppendBlob(final StorageUri blobAbsoluteUri)
Creates an instance of the class using the specified absolute URI and storage service client.
Parameters:
Throws:
CloudAppendBlob
public CloudAppendBlob(final StorageUri blobAbsoluteUri, final StorageCredentials credentials)
Creates an instance of the class using the specified absolute StorageUri and credentials.
Parameters:
Throws:
CloudAppendBlob
public CloudAppendBlob(final StorageUri blobAbsoluteUri, final String snapshotID, final StorageCredentials credentials)
Creates an instance of the class using the specified absolute StorageUri, snapshot ID, and credentials.
Parameters:
String
that represents the snapshot version, if applicable.
Throws:
CloudAppendBlob
public CloudAppendBlob(final URI blobAbsoluteUri)
Creates an instance of the class using the specified absolute URI and storage service client.
Parameters:
java.net.URI
object which represents the absolute URI to the blob.
Throws:
CloudAppendBlob
public CloudAppendBlob(final URI blobAbsoluteUri, final StorageCredentials credentials)
Creates an instance of the class using the specified absolute URI and credentials.
Parameters:
java.net.URI
object that represents the absolute URI to the blob.
Throws:
CloudAppendBlob
public CloudAppendBlob(final URI blobAbsoluteUri, final String snapshotID, final StorageCredentials credentials)
Creates an instance of the class using the specified absolute URI, snapshot ID, and credentials.
Parameters:
java.net.URI
object that represents the absolute URI to the blob.
String
that represents the snapshot version, if applicable.
Throws:
CloudAppendBlob
protected CloudAppendBlob(String blobName, String snapshotID, CloudBlobContainer container)
Creates an instance of the class using the specified type, name, snapshot ID, and container.
Parameters:
String
that represents the snapshot version, if applicable.
Throws:
Method Details
append
public void append(InputStream sourceStream, final long length)
Appends a stream to an append blob. This API should be used strictly in a single writer scenario because the API internally uses the append-offset conditional header to avoid duplicate blocks which does not work in a multiple writer scenario.
If you are doing writes in a single writer scenario, please look at setAbsorbConditionalErrorsOnRetry(final Boolean absorbConditionalErrorsOnRetry) and see if setting this flag to is acceptable for you.
Parameters:
long
which represents the length, in bytes, of the stream data, or -1 if unknown.
Throws:
append
public void append(InputStream sourceStream, final long length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext)
Appends a stream to an append blob. This API should be used strictly in a single writer scenario because the API internally uses the append-offset conditional header to avoid duplicate blocks which does not work in a multiple writer scenario.
If you are doing writes in a single writer scenario, please look at setAbsorbConditionalErrorsOnRetry(final Boolean absorbConditionalErrorsOnRetry) and see if setting this flag to is acceptable for you.
Parameters:
long
which represents the length, in bytes, of the stream data, or -1 if unknown.
null
will use the default request options from the associated service client ( CloudBlobClient).
Throws:
appendBlock
public Long appendBlock(final InputStream sourceStream, final long length)
Commits a new block of data to the end of the blob.
Parameters:
long
which represents the length, in bytes, of the stream data, or -1 if unknown.
Returns:
Throws:
appendBlock
public Long appendBlock(final InputStream sourceStream, final long length, final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext)
Commits a new block of data to the end of the blob.
Parameters:
long
which represents the length, in bytes, of the stream data, or -1 if unknown.
null
will use the default request options from the associated service client ( CloudBlobClient).
Returns:
Throws:
appendBlockFromURI
public Long appendBlockFromURI(final URI copySource, final Long offset, final Long length)
Appends a block, using the specified source URL.
Parameters:
URI
of the source data. It can point to any Azure Blob or File that is public or the URL can include a shared access signature.
long
which represents the offset to use as the starting point for the source.
Long
which represents the number of bytes to copy or null
to copy until the end of the blob.
Returns:
Throws:
appendBlockFromURI
public Long appendBlockFromURI(final URI copySource, final Long offset, final Long length, String md5, final AccessCondition accessCondition, final AccessCondition sourceAccessCondition, BlobRequestOptions options, OperationContext opContext)
Appends a block, using the specified source URL.
Parameters:
URI
of the source data. It can point to any Azure Blob or File that is public or the URL can include a shared access signature.
long
which represents the offset to use as the starting point for the source.
Long
which represents the number of bytes to copy or null
to copy until the end of the blob.
String
which represents the MD5 caluclated for the range of bytes of the source.
null
will use the default request options from the associated service client ( CloudBlobClient).
Returns:
Throws:
appendFromByteArray
public void appendFromByteArray(final byte[] buffer, final int offset, final int length)
Appends the contents of a byte array to an append blob.This API should be used strictly in a single writer scenario because the API internally uses the append-offset conditional header to avoid duplicate blocks which does not work in a multiple writer scenario.
If you are doing writes in a single writer scenario, please look at setAbsorbConditionalErrorsOnRetry(final Boolean absorbConditionalErrorsOnRetry) and see if setting this flag to is acceptable for you.
Parameters:
byte
array which represents the data to append to the blob.
int
which represents the offset of the byte array from which to start the data upload.
int
which represents the number of bytes to upload from the input buffer.
Throws:
appendFromByteArray
public void appendFromByteArray(final byte[] buffer, final int offset, final int length, final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext)
Appends the contents of a byte array to an append blob.This API should be used strictly in a single writer scenario because the API internally uses the append-offset conditional header to avoid duplicate blocks which does not work in a multiple writer scenario.
If you are doing writes in a single writer scenario, please look at setAbsorbConditionalErrorsOnRetry(final Boolean absorbConditionalErrorsOnRetry) and see if setting this flag to is acceptable for you.
Parameters:
byte
array which represents the data to append to the blob.
int
which represents the offset of the byte array from which to start the data upload.
int
which represents the number of bytes to upload from the input buffer.
null
will use the default request options from the associated service client ( CloudBlobClient).
Throws:
appendFromFile
public void appendFromFile(final String path)
Appends a file to an append blob. This API should be used strictly in a single writer scenario because the API internally uses the append-offset conditional header to avoid duplicate blocks which does not work in a multiple writer scenario.
If you are doing writes in a single writer scenario, please look at setAbsorbConditionalErrorsOnRetry(final Boolean absorbConditionalErrorsOnRetry) and see if setting this flag to is acceptable for you.
Parameters:
String
which represents the path to the file to be appended.
Throws:
appendFromFile
public void appendFromFile(final String path, final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext)
Appends a file to an append blob. This API should be used strictly in a single writer scenario because the API internally uses the append-offset conditional header to avoid duplicate blocks which does not work in a multiple writer scenario.
If you are doing writes in a single writer scenario, please look at setAbsorbConditionalErrorsOnRetry(final Boolean absorbConditionalErrorsOnRetry) and see if setting this flag to is acceptable for you.
Parameters:
String
which represents the path to the file to be appended.
null
will use the default request options from the associated service client ( CloudBlobClient).
Throws:
appendText
public void appendText(final String content)
Appends a string of text to an append blob using the platform's default encoding. This API should be used strictly in a single writer scenario because the API internally uses the append-offset conditional header to avoid duplicate blocks which does not work in a multiple writer scenario.
If you are doing writes in a single writer scenario, please look at setAbsorbConditionalErrorsOnRetry(final Boolean absorbConditionalErrorsOnRetry) and see if setting this flag to is acceptable for you.
Parameters:
String
which represents the content that will be appended to the blob.
Throws:
appendText
public void appendText(final String content, final String charsetName, final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext)
Appends a string of text to an append blob using the specified encoding. This API should be used strictly in a single writer scenario because the API internally uses the append-offset conditional header to avoid duplicate blocks which does not work in a multiple writer scenario.
If you are doing writes in a single writer scenario, please look at setAbsorbConditionalErrorsOnRetry(final Boolean absorbConditionalErrorsOnRetry) and see if setting this flag to is acceptable for you.
Parameters:
String
which represents the content that will be appended to the blob.
String
which represents the name of the charset to use to encode the content. If null, the platform's default encoding is used.
null
will use the default request options from the associated service client ( CloudBlobClient).
Throws:
createOrReplace
public void createOrReplace()
Creates an empty append blob. If the blob already exists, this will replace it.
To avoid overwriting and instead throw an error, please use the createOrReplace(final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext) overload with the appropriate AccessCondition.
Throws:
createOrReplace
public void createOrReplace(final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext)
Creates an append blob using the specified request options and operation context. If the blob already exists, this will replace it.
To avoid overwriting and instead throw an error, please pass in an AccessCondition generated using generateIfNotExistsCondition().
Parameters:
null
will use the default request options from the associated service client ( CloudBlobClient).
Throws:
openWriteExisting
public BlobOutputStream openWriteExisting()
Opens an output stream object to write data to the append blob. The append blob must already exist and will be appended to.
If you are doing writes in a single writer scenario, please look at setAbsorbConditionalErrorsOnRetry(final Boolean absorbConditionalErrorsOnRetry) and see if setting this flag to is acceptable for you.
Returns:
Throws:
openWriteExisting
public BlobOutputStream openWriteExisting(AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext)
Opens an output stream object to write data to the append blob, using the specified lease ID, request options and operation context. The append blob must already exist and will be appended to.
If you are doing writes in a single writer scenario, please look at setAbsorbConditionalErrorsOnRetry(final Boolean absorbConditionalErrorsOnRetry) and see if setting this flag to is acceptable for you.
Parameters:
null
will use the default request options from the associated service client ( CloudBlobClient).
Returns:
Throws:
openWriteNew
public BlobOutputStream openWriteNew()
Opens an output stream object to write data to the append blob. The append blob does not need to yet exist. If the blob already exists, this will replace it.
To avoid overwriting and instead throw an error, please use the openWriteNew(AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext) overload with the appropriate AccessCondition.
If you are doing writes in a single writer scenario, please look at setAbsorbConditionalErrorsOnRetry(final Boolean absorbConditionalErrorsOnRetry) and see if setting this flag to is acceptable for you.
Returns:
Throws:
openWriteNew
public BlobOutputStream openWriteNew(AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext)
Opens an output stream object to write data to the append blob, using the specified lease ID, request options and operation context. The append blob does not need to yet exist. If the blob already exists, this will replace it.
To avoid overwriting and instead throw an error, please pass in an AccessCondition generated using generateIfNotExistsCondition().
If you are doing writes in a single writer scenario, please look at setAbsorbConditionalErrorsOnRetry(final Boolean absorbConditionalErrorsOnRetry) and see if setting this flag to is acceptable for you.
Parameters:
null
will use the default request options from the associated service client ( CloudBlobClient).
Returns:
Throws:
setStreamWriteSizeInBytes
public void setStreamWriteSizeInBytes(final int streamWriteSizeInBytes)
Sets the number of bytes to buffer when writing to a BlobOutputStream.
Parameters:
int
which represents the maximum block size, in bytes, for writing to an append blob while using a BlobOutputStream object, ranging from 16 KB to 4 MB, inclusive.
Throws:
streamWriteSizeInBytes
is less than 16 KB or greater than 4 MB.
startCopy
public final String startCopy(final CloudAppendBlob sourceBlob)
Requests the service to start copying a append blob's contents, properties, and metadata to a new append blob.
Parameters:
CloudAppendBlob
object that represents the source blob to copy.
Returns:
String
which represents the copy ID associated with the copy operation.Throws:
startCopy
public final String startCopy(final CloudAppendBlob sourceBlob, final AccessCondition sourceAccessCondition, final AccessCondition destinationAccessCondition, BlobRequestOptions options, OperationContext opContext)
Requests the service to start copying a append blob's contents, properties, and metadata to a new append blob, using the specified access conditions, lease ID, request options, and operation context.
Parameters:
CloudAppendBlob
object that represents the source blob to copy.
null
will use the default request options from the associated service client ( CloudBlobClient).
Returns:
String
which represents the copy ID associated with the copy operation.Throws:
upload
public void upload(final InputStream sourceStream, final long length)
Uploads the source stream data to the append blob. If the blob already exists on the service, it will be overwritten.
If you want to append data to an already existing blob, please see appendBlock(final InputStream sourceStream, final long length).
If you are doing writes in a single writer scenario, please look at setAbsorbConditionalErrorsOnRetry(final Boolean absorbConditionalErrorsOnRetry) and see if setting this flag to is acceptable for you.
Parameters:
long
which represents the length, in bytes, of the stream data, or -1 if unknown.
Throws:
upload
public void upload(final InputStream sourceStream, final long length, final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext)
Uploads the source stream data to the append blob using the specified lease ID, request options, and operation context. If the blob already exists on the service, it will be overwritten.
If you want to append data to an already existing blob, please see appendBlock(final InputStream sourceStream, final long length).
If you are doing writes in a single writer scenario, please look at setAbsorbConditionalErrorsOnRetry(final Boolean absorbConditionalErrorsOnRetry) and see if setting this flag to is acceptable for you.
Parameters:
long
which represents the length, in bytes, of the stream data, or -1 if unknown.
null
will use the default request options from the associated service client ( CloudBlobClient).
Throws:
Applies to
Azure SDK for Java