CloudBlob Class

Definition

Represents a Microsoft Azure blob. This is the base class for the CloudBlockBlob and CloudPageBlob classes.

public class CloudBlob implements ListBlobItem
Inheritance
java.lang.Object
CloudBlob

Constructors

CloudBlob(final BlobType type, final StorageUri uri, final String snapshotID, final StorageCredentials credentials)

Creates an instance of the class using the specified URI, snapshot ID, and cloud blob client.

CloudBlob(final BlobType type, String blobName, String snapshotID, CloudBlobContainer container)

Creates an instance of the class using the specified type, name, snapshot ID, and container.

CloudBlob(final CloudBlob otherBlob)

Creates an instance of the class by copying values from another blob.

Fields

blobServiceClient

Represents the blob client.

parent

Represents the blob's directory.

streamMinimumReadSizeInBytes

Holds the minimum read size when using a BlobInputStream.

streamWriteSizeInBytes

Holds the number of bytes to buffer when writing to a BlobOutputStream (block and page blobs).

Methods

abortCopy(final String copyId)

Aborts an ongoing blob copy operation.

abortCopy(final String copyId, final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext)

Aborts an ongoing blob copy operation.

acquireLease()

Acquires a new infinite lease on the blob.

acquireLease(final Integer leaseTimeInSeconds, final String proposedLeaseId)

Acquires a new lease on the blob with the specified lease time and proposed lease ID.

acquireLease(final Integer leaseTimeInSeconds, final String proposedLeaseId, final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext)

Acquires a new lease on the blob with the specified lease time, proposed lease ID, request options, and operation context.

assertCorrectBlobType()

Asserts that the blob has the correct blob type specified in the blob attributes.

assertNoWriteOperationForSnapshot()

Asserts that write operation is not done for snapshot.

breakLease(final Integer breakPeriodInSeconds)

Breaks the lease and ensures that another client cannot acquire a new lease until the current lease period has expired.

breakLease(final Integer breakPeriodInSeconds, final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext)

Breaks the existing lease, using the specified request options and operation context, and ensures that another client cannot acquire a new lease until the current lease period has expired.

changeLease(final String proposedLeaseId, final AccessCondition accessCondition)

Changes the existing lease ID to the proposed lease ID.

changeLease(final String proposedLeaseId, final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext)

Changes the existing lease ID to the proposed lease Id with the specified access conditions, request options, and operation context.

createSnapshot()

Creates a snapshot of the blob.

createSnapshot(final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext)

Creates a snapshot of the blob using the specified request options and operation context.

createSnapshot(final HashMap<String, String> metadata, final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext)

Creates a snapshot of the blob using the specified request options and operation context.

delete()

Deletes the blob.

delete(final DeleteSnapshotsOption deleteSnapshotsOption, final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext)

Deletes the blob using the specified snapshot and request options, and operation context.

A blob that has snapshots cannot be deleted unless the snapshots are also deleted. If a blob has snapshots, use the DeleteSnapshotsOption#DELETE_SNAPSHOTS_ONLY or DeleteSnapshotsOption#INCLUDE_SNAPSHOTS value in the parameter to specify how the snapshots should be handled when the blob is deleted.

deleteIfExists()

Deletes the blob if it exists.

A blob that has snapshots cannot be deleted unless the snapshots are also deleted. If a blob has snapshots, use the DeleteSnapshotsOption#DELETE_SNAPSHOTS_ONLY or DeleteSnapshotsOption#INCLUDE_SNAPSHOTS value in the parameter to specify how the snapshots should be handled when the blob is deleted.

deleteIfExists(final DeleteSnapshotsOption deleteSnapshotsOption, final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext)

Deletes the blob if it exists, using the specified snapshot and request options, and operation context.

A blob that has snapshots cannot be deleted unless the snapshots are also deleted. If a blob has snapshots, use the DeleteSnapshotsOption#DELETE_SNAPSHOTS_ONLY or DeleteSnapshotsOption#INCLUDE_SNAPSHOTS value in the parameter to specify how the snapshots should be handled when the blob is deleted.

download(final OutputStream outStream)

Downloads the contents of a blob to a stream.

download(final OutputStream outStream, final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext)

Downloads the contents of a blob to a stream using the specified request options and operation context.

downloadAttributes()

Populates a blob's properties and metadata.

This method populates the blob's system properties and user-defined metadata. Before reading or modifying a blob's properties or metadata, call this method or its overload to retrieve the latest values for the blob's properties and metadata from the Microsoft Azure storage service.

downloadAttributes(final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext)

Populates a blob's properties and metadata using the specified request options and operation context.

This method populates the blob's system properties and user-defined metadata. Before reading or modifying a blob's properties or metadata, call this method or its overload to retrieve the latest values for the blob's properties and metadata from the Microsoft Azure storage service.

downloadRange(final long offset, final Long length, final OutputStream outStream)

Downloads the contents of a blob to a stream.

downloadRange(final long offset, final Long length, final OutputStream outStream, final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext)

Downloads the contents of a blob to a stream using the specified request options and operation context.

downloadRangeInternal(final long blobOffset, final Long length, final byte[] buffer, final int bufferOffset, final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext)

Downloads a range of bytes from the blob to the given byte buffer.

downloadRangeToByteArray(final long offset, final Long length, final byte[] buffer, final int bufferOffset)

Downloads a range of bytes from the blob to the given byte buffer.

downloadRangeToByteArray(final long offset, final Long length, final byte[] buffer, final int bufferOffset, final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext)

Downloads a range of bytes from the blob to the given byte buffer, using the specified request options and operation context.

downloadToByteArray(final byte[] buffer, final int bufferOffset)

Downloads a range of bytes from the blob to the given byte buffer.

downloadToByteArray(final byte[] buffer, final int bufferOffset, final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext)

Downloads a range of bytes from the blob to the given byte buffer, using the specified request options and operation context.

downloadToFile(final String path)

Downloads a blob, storing the contents in a file.

downloadToFile(final String path, final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext)

Downloads a blob, storing the contents in a file.

exists()

Checks to see if the blob exists.

exists(final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext)

Checks to see if the blob exists, using the specified request options and operation context.

generateSharedAccessSignature(final SharedAccessBlobPolicy policy, final SharedAccessBlobHeaders headers, final String groupPolicyIdentifier)

Returns a shared access signature for the blob using the specified group policy identifier and operation context. Note this does not contain the leading "?".

generateSharedAccessSignature(final SharedAccessBlobPolicy policy, final SharedAccessBlobHeaders headers, final String groupPolicyIdentifier, final IPRange ipRange, final SharedAccessProtocols protocols)

Returns a shared access signature for the blob using the specified group policy identifier and operation context. Note this does not contain the leading "?".

generateSharedAccessSignature(final SharedAccessBlobPolicy policy, final String groupPolicyIdentifier)

Returns a shared access signature for the blob using the specified group policy identifier and operation context. Note this does not contain the leading "?".

getContainer()

Returns the blob's container.

getCopyState()

Returns the blob's copy state.

getMetadata()

Returns the metadata for the blob.

getName()

Returns the name of the blob.

getParent()

Returns the blob item's parent.

getParentNameFromURI(final StorageUri resourceAddress, final String delimiter, final CloudBlobContainer container)

Retrieves the parent name for a blob URI.

getProperties()

Returns the blob's properties.

getQualifiedStorageUri()

Returns the snapshot and/or shared access signature qualified URI for this blob.

Deprecated

use getSnapshotQualifiedStorageUri() instead.

</xrefdescription>

getQualifiedUri()

Returns the snapshot or shared access signature qualified URI for this blob.

Deprecated

use getSnapshotQualifiedUri() instead.

</xrefdescription>

getServiceClient()

Returns the Blob service client associated with the blob.

getSnapshotID()

Gets the Blob Snapshot ID.

getSnapshotQualifiedStorageUri()

Returns the blob's URI for both the primary and secondary locations, including query string information if the blob is a snapshot.

getSnapshotQualifiedUri()

Returns the absolute URI to the blob, including query string information if the blob is a snapshot.

getStorageUri()

Returns the list of URIs for all locations.

getStreamMinimumReadSizeInBytes()

Returns the minimum read size when using a BlobInputStream.

getStreamWriteSizeInBytes()

Gets the number of bytes to buffer when writing to a BlobOutputStream (block and page blobs).

getTransformedAddress(final OperationContext opContext)

Returns the transformed URI for the resource if the given credentials require transformation.

getUri()

Returns the URI for this blob.

isSnapshot()

Indicates whether this blob is a snapshot.

openInputStream()

Opens a blob input stream to download the blob.

Use setStreamMinimumReadSizeInBytes(int) to configure the read size.

openInputStream(final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext)

Opens a blob input stream to download the blob using the specified request options and operation context.

Use setStreamMinimumReadSizeInBytes(int) to configure the read size.

releaseLease(final AccessCondition accessCondition)

Releases the lease on the blob.

releaseLease(final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext)

Releases the lease on the blob using the specified request options and operation context.

renewLease(final AccessCondition accessCondition)

Renews an existing lease.

renewLease(final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext)

Renews an existing lease using the specified request options and operation context.

setContainer(final CloudBlobContainer container)

Sets the container for the blob.

setMetadata(final HashMap<String, String> metadata)

Sets the metadata for the blob.

setProperties(final BlobProperties properties)

Sets the properties for the blob.

setSnapshotID(final String snapshotID)

Sets the blob snapshot ID.

setStorageUri(final StorageUri storageUri)

Sets the list of URIs for all locations.

setStreamMinimumReadSizeInBytes(final int minimumReadSize)

Sets the minimum read size when using a BlobInputStream.

setStreamWriteSizeInBytes(int streamWriteSizeInBytes)

Sets the number of bytes to buffer when writing to a BlobOutputStream (block and page blobs).

startCopy(final URI source)

Requests the service to start copying a URI's contents, properties, and metadata to a new blob.

startCopy(final URI source, final AccessCondition sourceAccessCondition, final AccessCondition destinationAccessCondition, BlobRequestOptions options, OperationContext opContext)

Requests the service to start copying a URI's contents, properties, and metadata to a new blob, using the specified access conditions, lease ID, request options, and operation context.

startCopy(final URI source, final PremiumPageBlobTier premiumPageBlobTier, final AccessCondition sourceAccessCondition, final AccessCondition destinationAccessCondition, BlobRequestOptions options, OperationContext opContext)

Requests the service to start copying a URI's contents, properties, and metadata to a new blob, using the specified premium page blob tier, access conditions, lease ID, request options, and operation context.

Note: Setting the premiumPageBlobTier is only supported for premium accounts.

startCopyImpl(final URI source, final boolean incrementalCopy, final PremiumPageBlobTier premiumPageBlobTier, final AccessCondition sourceAccessCondition, final AccessCondition destinationAccessCondition, final BlobRequestOptions options)
updateEtagAndLastModifiedFromResponse(HttpURLConnection request)
updateLengthFromResponse(HttpURLConnection request)
upload(InputStream sourceStream, long length)

Uploads the source stream data to the blob. If the blob already exists on the service, it will be overwritten.

upload(InputStream sourceStream, 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.

uploadBlobTierImpl(final String blobTierString, final BlobRequestOptions options)
uploadFromByteArray(final byte[] buffer, final int offset, final int length)

Uploads a blob from data in a byte array. If the blob already exists on the service, it will be overwritten.

uploadFromByteArray(final byte[] buffer, final int offset, final int length, 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.

uploadFromFile(final String path)

Uploads a blob from a file. If the blob already exists on the service, it will be overwritten.

uploadFromFile(final String path, final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext)

Uploads a blob from a file. If the blob already exists on the service, it will be overwritten.

uploadMetadata()

Uploads the blob's metadata to the storage service.

Use CloudBlob#downloadAttributes to retrieve the latest values for the blob's properties and metadata from the Microsoft Azure storage service.

uploadMetadata(final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext)

Uploads the blob's metadata to the storage service using the specified lease ID, request options, and operation context.

Use CloudBlob#downloadAttributes to retrieve the latest values for the blob's properties and metadata from the Microsoft Azure storage service.

uploadProperties()

Updates the blob's properties to the storage service.

Use CloudBlob#downloadAttributes to retrieve the latest values for the blob's properties and metadata from the Microsoft Azure storage service.

uploadProperties(final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext)

Updates the blob's properties using the specified lease ID, request options, and operation context.

Use CloudBlob#downloadAttributes to retrieve the latest values for the blob's properties and metadata from the Microsoft Azure storage service.