CloudBlockBlob Class
- java.
lang. Object - ListBlobItem
- CloudBlob
- com.
microsoft. azure. storage. blob. CloudBlockBlob
- com.
public class CloudBlockBlob extends CloudBlob
Represents a blob that is uploaded as a set of blocks.
Constructor Summary
Constructor | Description |
---|---|
CloudBlockBlob(final CloudBlockBlob otherBlob) |
Creates an instance of the class by copying values from another cloud block blob. |
CloudBlockBlob(final StorageUri blobAbsoluteUri) |
Creates an instance of the class using the specified absolute StorageUri. |
CloudBlockBlob(final StorageUri blobAbsoluteUri, final StorageCredentials credentials) |
Creates an instance of the class using the specified absolute StorageUri and credentials. |
CloudBlockBlob(final StorageUri blobAbsoluteUri, final String snapshotID, final StorageCredentials credentials) |
Creates an instance of the class using the specified absolute StorageUri, snapshot ID, and credentials. |
CloudBlockBlob(final URI blobAbsoluteUri) |
Creates an instance of the class using the specified absolute URI. |
CloudBlockBlob(final URI blobAbsoluteUri, final StorageCredentials credentials) |
Creates an instance of the class using the specified absolute URI and credentials. |
CloudBlockBlob(final URI blobAbsoluteUri, final String snapshotID, final StorageCredentials credentials) |
Creates an instance of the class using the specified absolute URI, snapshot ID, and credentials. |
CloudBlockBlob(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 |
commitBlockList(final Iterable<BlockEntry> blockList)
Commits a block list to the storage service. In order to be written as part of a blob, a block must have been successfully written to the server in a prior uploadBlock operation. |
void |
commitBlockList(final Iterable<BlockEntry> blockList, final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext)
Commits a block list to the storage service using the specified lease ID, request options, and operation context. In order to be written as part of a blob, a block must have been successfully written to the server in a prior uploadBlock operation. |
void |
commitBlockList(final Iterable<BlockEntry> blockList, StandardBlobTier standardBlobTier, final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext)
Commits a block list to the storage service using the specified lease ID, request options, and operation context. In order to be written as part of a blob, a block must have been successfully written to the server in a prior uploadBlock operation. |
void |
createBlockFromURI(final String blockId, final URI copySource, final Long offset, final Long length)
Creates a block to be committed as part of the block blob, using the specified block ID and the source URL. |
void |
createBlockFromURI(final String blockId, final URI copySource, final Long offset, final Long length, String md5, final AccessCondition sourceAccessCondition, BlobRequestOptions options, OperationContext opContext)
Creates a block to be committed as part of the block blob, using the specified block ID, the specified source URL, the specified lease ID, request options, and operation context. |
ArrayList<Block |
downloadBlockList()
Downloads the committed block list from the block blob. The committed block list includes the list of blocks that have been successfully committed to the block blob. The list of committed blocks is returned in the same order that they were committed to the blob. No block may appear more than once in the committed block list. |
ArrayList<Block |
downloadBlockList(final BlockListingFilter blockListingFilter, final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext)
Downloads the block list from the block blob using the specified block listing filter, request options, and operation context. The committed block list includes the list of blocks that have been successfully committed to the block blob. The list of committed blocks is returned in the same order that they were committed to the blob. No block may appear more than once in the committed block list. |
String |
downloadText()
Downloads a blob to a string using the platform's default encoding. |
String |
downloadText(final String charsetName, final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext)
Downloads a blob to a string using the specified encoding. |
boolean |
isStreamWriteSizeModified()
Gets the flag that indicates whether the default streamWriteSize was modified. |
Blob |
openOutputStream()
Creates and opens an output stream to write data to the block blob. If the blob already exists on the service, it will be overwritten. To avoid overwriting and instead throw an error, please use the openOutputStream(AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext) overload with the appropriate AccessCondition. |
Blob |
openOutputStream(AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext)
Creates and opens an output stream to write data to the block blob using the specified request options and operation context. If the blob already exists on the service, it will be overwritten. To avoid overwriting and instead throw an error, please pass in an AccessCondition generated using generateIfNotExistsCondition(). |
void |
setStreamWriteSizeInBytes(final int streamWriteSizeInBytes)
Sets the number of bytes to buffer when writing to a BlobOutputStream. |
final String |
startCopy(final CloudBlockBlob sourceBlob)
Requests the service to start copying a block blob's contents, properties, and metadata to a new block blob. |
final String |
startCopy(final CloudBlockBlob sourceBlob, final AccessCondition sourceAccessCondition, final AccessCondition destinationAccessCondition, BlobRequestOptions options, OperationContext opContext)
Requests the service to start copying a block blob's contents, properties, and metadata to a new block blob, using the specified access conditions, lease ID, request options, and operation context. |
final String |
startCopy(final CloudBlockBlob sourceBlob, String contentMd5, boolean syncCopy, final AccessCondition sourceAccessCondition, final AccessCondition destinationAccessCondition, BlobRequestOptions options, OperationContext opContext)
Requests the service to start copying a block blob's contents, properties, and metadata to a new block blob, using the specified access conditions, lease ID, request options, and operation context. |
final String |
startCopy(final CloudBlockBlob sourceBlob, String contentMd5, boolean syncCopy, final StandardBlobTier standardBlobTier, RehydratePriority rehydratePriority, final AccessCondition sourceAccessCondition, final AccessCondition destinationAccessCondition, BlobRequestOptions options, OperationContext opContext)
Requests the service to start copying a block blob's contents, properties, and metadata to a new block blob, using the blob tier, rehydrate priority, specified access conditions, lease ID, request options, operation context. |
final String |
startCopy(final CloudFile sourceFile)
Requests the service to start copying a file's contents, properties, and metadata to a new block blob. |
final String |
startCopy(final CloudFile sourceFile, final AccessCondition sourceAccessCondition, final AccessCondition destinationAccessCondition, BlobRequestOptions options, OperationContext opContext)
Requests the service to start copying a file's contents, properties, and metadata to a new block 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 block blob. If the blob already exists on the service, it will be overwritten. |
void |
upload(final InputStream sourceStream, final long length, final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext)
Uploads the source stream data to the blob, using the specified lease ID, request options, and operation context. If the blob already exists on the service, it will be overwritten. |
void |
upload(final InputStream sourceStream, final long length, final StandardBlobTier standardBlobTier, final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext)
Uploads the source stream data to the blob, using the specified lease ID, request options, and operation context. If the blob already exists on the service, it will be overwritten. |
void |
uploadBlock(final String blockId, final InputStream sourceStream, final long length)
Uploads a block to be committed as part of the block blob, using the specified block ID. |
void |
uploadBlock(final String blockId, final InputStream sourceStream, final long length, final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext)
Uploads a block to be committed as part of the block blob, using the specified block ID, the specified lease ID, request options, and operation context. |
void |
uploadFromByteArray(final byte[] buffer, final int offset, final int length, final StandardBlobTier standardBlobTier, final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext)
Uploads a blob from data in a byte array. If the blob already exists on the service, it will be overwritten. |
final void |
uploadFullBlob(final InputStream sourceStream, final long length, final StandardBlobTier standardBlobTier, final AccessCondition accessCondition, final BlobRequestOptions options, final OperationContext opContext)
Uploads a blob in a single operation. |
void |
uploadStandardBlobTier(final StandardBlobTier standardBlobTier)
Sets the blob tier on a block blob on a standard storage account. |
void |
uploadStandardBlobTier(final StandardBlobTier standardBlobTier, BlobRequestOptions options, OperationContext opContext)
Sets the tier on a block blob on a standard storage account. |
void |
uploadStandardBlobTier(final StandardBlobTier standardBlobTier, RehydratePriority rehydratePriority, BlobRequestOptions options, OperationContext opContext)
Sets the tier on a block blob on a standard storage account. |
void |
uploadText(final String content)
Uploads a blob from a string using the platform's default encoding. If the blob already exists on the service, it will be overwritten. |
void |
uploadText(final String content, final String charsetName, final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext)
Uploads a blob from a string using the specified encoding. If the blob already exists on the service, it will be overwritten. |
void |
uploadText(final String content, final String charsetName, final StandardBlobTier standardBlobTier, final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext)
Uploads a blob from a string using the specified encoding. If the blob already exists on the service, it will be overwritten. |
Inherited Members
Constructor Details
CloudBlockBlob
public CloudBlockBlob(final CloudBlockBlob otherBlob)
Creates an instance of the class by copying values from another cloud block blob.
Parameters:
CloudBlockBlob
object that represents the block blob to copy.
CloudBlockBlob
public CloudBlockBlob(final StorageUri blobAbsoluteUri)
Creates an instance of the class using the specified absolute StorageUri.
Parameters:
Throws:
CloudBlockBlob
public CloudBlockBlob(final StorageUri blobAbsoluteUri, final StorageCredentials credentials)
Creates an instance of the class using the specified absolute StorageUri and credentials.
Parameters:
Throws:
CloudBlockBlob
public CloudBlockBlob(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:
CloudBlockBlob
public CloudBlockBlob(final URI blobAbsoluteUri)
Creates an instance of the class using the specified absolute URI.
Parameters:
java.net.URI
object that represents the absolute URI to the blob.
Throws:
CloudBlockBlob
public CloudBlockBlob(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:
CloudBlockBlob
public CloudBlockBlob(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:
CloudBlockBlob
protected CloudBlockBlob(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
commitBlockList
public void commitBlockList(final Iterable
Commits a block list to the storage service. In order to be written as part of a blob, a block must have been successfully written to the server in a prior uploadBlock operation.
Parameters:
size
field is ignored.
Throws:
commitBlockList
public void commitBlockList(final Iterable
Commits a block list to the storage service using the specified lease ID, request options, and operation context. In order to be written as part of a blob, a block must have been successfully written to the server in a prior uploadBlock operation.
Parameters:
null
will use the default request options from the associated service client ( CloudBlobClient).
Throws:
commitBlockList
public void commitBlockList(final Iterable
Commits a block list to the storage service using the specified lease ID, request options, and operation context. In order to be written as part of a blob, a block must have been successfully written to the server in a prior uploadBlock operation.
Parameters:
null
will use the default request options from the associated service client ( CloudBlobClient).
Throws:
createBlockFromURI
public void createBlockFromURI(final String blockId, final URI copySource, final Long offset, final Long length)
Creates a block to be committed as part of the block blob, using the specified block ID and the source URL.
Parameters:
String
that represents the Base-64 encoded block ID. Note for a given blob the length of all Block IDs must be identical.
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.
Throws:
createBlockFromURI
public void createBlockFromURI(final String blockId, final URI copySource, final Long offset, final Long length, String md5, final AccessCondition sourceAccessCondition, BlobRequestOptions options, OperationContext opContext)
Creates a block to be committed as part of the block blob, using the specified block ID, the specified source URL, the specified lease ID, request options, and operation context.
Parameters:
String
that represents the Base-64 encoded block ID. Note for a given blob the length of all Block IDs must be identical.
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).
Throws:
downloadBlockList
public ArrayList
Downloads the committed block list from the block blob.
The committed block list includes the list of blocks that have been successfully committed to the block blob. The list of committed blocks is returned in the same order that they were committed to the blob. No block may appear more than once in the committed block list.
Returns:
ArrayList
object of BlockEntry objects that represent the committed list block items downloaded from the block blob.Throws:
downloadBlockList
public ArrayList
Downloads the block list from the block blob using the specified block listing filter, request options, and operation context.
The committed block list includes the list of blocks that have been successfully committed to the block blob. The list of committed blocks is returned in the same order that they were committed to the blob. No block may appear more than once in the committed block list.
Parameters:
null
will use the default request options from the associated service client ( CloudBlobClient).
Returns:
ArrayList
object of BlockEntry objects that represent the list block items downloaded from the block blob.Throws:
downloadText
public String downloadText()
Downloads a blob to a string using the platform's default encoding.
Returns:
String
which represents the blob's contents.Throws:
downloadText
public String downloadText(final String charsetName, final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext)
Downloads a blob to a string using the specified encoding.
Parameters:
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).
Returns:
String
which represents the blob's contents.Throws:
isStreamWriteSizeModified
public boolean isStreamWriteSizeModified()
Gets the flag that indicates whether the default streamWriteSize was modified.
openOutputStream
public BlobOutputStream openOutputStream()
Creates and opens an output stream to write data to the block blob. If the blob already exists on the service, it will be overwritten.
To avoid overwriting and instead throw an error, please use the openOutputStream(AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext) overload with the appropriate AccessCondition.
Returns:
Throws:
openOutputStream
public BlobOutputStream openOutputStream(AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext)
Creates and opens an output stream to write data to the block blob using the specified request options and operation context. If the blob already exists on the service, it will be overwritten.
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).
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 a block blob while using a BlobOutputStream object, ranging from 16 KB to 100 MB, inclusive.
Throws:
streamWriteSizeInBytes
is less than 16 KB or greater than 100 MB.
startCopy
public final String startCopy(final CloudBlockBlob sourceBlob)
Requests the service to start copying a block blob's contents, properties, and metadata to a new block blob.
Parameters:
CloudBlockBlob
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 CloudBlockBlob sourceBlob, final AccessCondition sourceAccessCondition, final AccessCondition destinationAccessCondition, BlobRequestOptions options, OperationContext opContext)
Requests the service to start copying a block blob's contents, properties, and metadata to a new block blob, using the specified access conditions, lease ID, request options, and operation context.
Parameters:
CloudBlockBlob
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:
startCopy
public final String startCopy(final CloudBlockBlob sourceBlob, String contentMd5, boolean syncCopy, final AccessCondition sourceAccessCondition, final AccessCondition destinationAccessCondition, BlobRequestOptions options, OperationContext opContext)
Requests the service to start copying a block blob's contents, properties, and metadata to a new block blob, using the specified access conditions, lease ID, request options, and operation context.
Parameters:
CloudBlockBlob
object that represents the source blob to copy.
null
or empty.
boolean
to enable synchronous server copy of blobs.
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:
startCopy
public final String startCopy(final CloudBlockBlob sourceBlob, String contentMd5, boolean syncCopy, final StandardBlobTier standardBlobTier, RehydratePriority rehydratePriority, final AccessCondition sourceAccessCondition, final AccessCondition destinationAccessCondition, BlobRequestOptions options, OperationContext opContext)
Requests the service to start copying a block blob's contents, properties, and metadata to a new block blob, using the blob tier, rehydrate priority, specified access conditions, lease ID, request options, operation context.
Parameters:
CloudBlockBlob
object that represents the source blob to copy.
null
or empty.
boolean
to enable synchronous server copy of blobs.
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:
startCopy
public final String startCopy(final CloudFile sourceFile)
Requests the service to start copying a file's contents, properties, and metadata to a new block blob.
Parameters:
CloudFile
object that represents the source file to copy.
Returns:
String
which represents the copy ID associated with the copy operation.Throws:
startCopy
public final String startCopy(final CloudFile sourceFile, final AccessCondition sourceAccessCondition, final AccessCondition destinationAccessCondition, BlobRequestOptions options, OperationContext opContext)
Requests the service to start copying a file's contents, properties, and metadata to a new block blob, using the specified access conditions, lease ID, request options, and operation context.
Parameters:
CloudFile
object that represents the source file 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 block blob. If the blob already exists on the service, it will be overwritten.
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 blob, using the specified lease ID, request options, and operation context. If the blob already exists on the service, it will be overwritten.
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:
upload
public void upload(final InputStream sourceStream, final long length, final StandardBlobTier standardBlobTier, final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext)
Uploads the source stream data to the blob, using the specified lease ID, request options, and operation context. If the blob already exists on the service, it will be overwritten.
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:
uploadBlock
public void uploadBlock(final String blockId, final InputStream sourceStream, final long length)
Uploads a block to be committed as part of the block blob, using the specified block ID.
Parameters:
String
that represents the Base-64 encoded block ID. Note for a given blob the length of all Block IDs must be identical.
long
which represents the length, in bytes, of the stream data, or -1 if unknown.
Throws:
uploadBlock
public void uploadBlock(final String blockId, final InputStream sourceStream, final long length, final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext)
Uploads a block to be committed as part of the block blob, using the specified block ID, the specified lease ID, request options, and operation context.
Parameters:
String
that represents the Base-64 encoded block ID. Note for a given blob the length of all Block IDs must be identical.
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:
uploadFromByteArray
public void uploadFromByteArray(final byte[] buffer, final int offset, final int length, final StandardBlobTier standardBlobTier, final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext)
Uploads a blob from data in a byte array. If the blob already exists on the service, it will be overwritten.
Parameters:
byte
array which represents the data to write 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:
uploadFullBlob
protected final void uploadFullBlob(final InputStream sourceStream, final long length, final StandardBlobTier standardBlobTier, final AccessCondition accessCondition, final BlobRequestOptions options, final OperationContext opContext)
Uploads a blob in a single operation.
Parameters:
InputStream
object that represents the source stream to upload.
null
will use the default request options from the associated service client ( CloudBlobClient).
Throws:
uploadStandardBlobTier
public void uploadStandardBlobTier(final StandardBlobTier standardBlobTier)
Sets the blob tier on a block blob on a standard storage account.
Parameters:
Throws:
uploadStandardBlobTier
public void uploadStandardBlobTier(final StandardBlobTier standardBlobTier, BlobRequestOptions options, OperationContext opContext)
Sets the tier on a block blob on a standard storage account.
Parameters:
null
will use the default request options from the associated service client ( CloudBlobClient).
Throws:
uploadStandardBlobTier
public void uploadStandardBlobTier(final StandardBlobTier standardBlobTier, RehydratePriority rehydratePriority, BlobRequestOptions options, OperationContext opContext)
Sets the tier on a block blob on a standard storage account.
Parameters:
null
will use the default request options from the associated service client ( CloudBlobClient).
Throws:
uploadText
public void uploadText(final String content)
Uploads a blob from a string using the platform's default encoding. If the blob already exists on the service, it will be overwritten.
Parameters:
String
which represents the content that will be uploaded to the blob.
Throws:
uploadText
public void uploadText(final String content, final String charsetName, final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext)
Uploads a blob from a string using the specified encoding. If the blob already exists on the service, it will be overwritten.
Parameters:
String
which represents the content that will be uploaded 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:
uploadText
public void uploadText(final String content, final String charsetName, final StandardBlobTier standardBlobTier, final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext)
Uploads a blob from a string using the specified encoding. If the blob already exists on the service, it will be overwritten.
Parameters:
String
which represents the content that will be uploaded 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:
Applies to
Azure SDK for Java