CloudBlob Class

  • java.lang.Object

public class CloudBlob implements ListBlobItem

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

Field Summary

Modifier and Type Field and Description
CloudBlobClient blobServiceClient

Represents the blob client.

CloudBlobDirectory parent

Represents the blob's directory.

int streamMinimumReadSizeInBytes

Holds the minimum read size when using a BlobInputStream.

int streamWriteSizeInBytes

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

Constructor Summary

Constructor Description
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.

Method Summary

Modifier and Type Method and Description
final void abortCopy(final String copyId)

Aborts an ongoing blob copy operation.

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

Aborts an ongoing blob copy operation.

final String acquireLease()

Acquires a new infinite lease on the blob.

final String acquireLease(final Integer leaseTimeInSeconds, final String proposedLeaseId)

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

final String 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.

final void assertCorrectBlobType()

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

void assertNoWriteOperationForSnapshot()

Asserts that write operation is not done for snapshot.

final long breakLease(final Integer breakPeriodInSeconds)

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

final long 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.

final String changeLease(final String proposedLeaseId, final AccessCondition accessCondition)

Changes the existing lease ID to the proposed lease ID.

final String 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.

final CloudBlob createSnapshot()

Creates a snapshot of the blob.

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

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

final CloudBlob 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.

final void delete()

Deletes the blob.

If a delete retention policy is enabled on the service, the blob will be retained for a specified period of time, before being removed permanently by garbage collection.

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

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

If a delete retention policy is enabled on the service, the blob will be retained for a specified period of time, before being removed permanently by garbage collection.

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

final boolean 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 DELETE_SNAPSHOTS_ONLY or INCLUDE_SNAPSHOTS value in the parameter to specify how the snapshots should be handled when the blob is deleted.

final boolean 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 DELETE_SNAPSHOTS_ONLY or INCLUDE_SNAPSHOTS value in the parameter to specify how the snapshots should be handled when the blob is deleted.

final void download(final OutputStream outStream)

Downloads the contents of a blob to a stream.

final void 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.

AccountInformation downloadAccountInfo()

Gets information related to the storage account in which this blob resides.

AccountInformation downloadAccountInfo(BlobRequestOptions options, OperationContext opContext)

Gets information related to the storage account in which this blob resides.

StorageRequest<ServiceClient, CloudBlob, AccountInformation> downloadAccountInformationImpl(final RequestOptions options)
final void 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.

final void 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.

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

Downloads the contents of a blob to a stream.

final void 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.

final int 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.

final int 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.

final int 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.

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

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

final int 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.

void downloadToFile(final String path)

Downloads a blob, storing the contents in a file.

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

Downloads a blob, storing the contents in a file.

final boolean exists()

Checks to see if the blob exists.

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

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

String 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 "?".

String 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 "?".

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

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

String 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 "?".

String generateUserDelegationSharedAccessSignature(final UserDelegationKey delegationKey, final SharedAccessBlobPolicy policy, final SharedAccessBlobHeaders headers, final IPRange ipRange, final SharedAccessProtocols protocols)

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

String generateUserDelegationSharedAccessSignature(UserDelegationKey delegationKey, SharedAccessBlobPolicy policy)

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

final CloudBlobContainer getContainer()

Returns the blob's container.

CopyState getCopyState()

Returns the blob's copy state.

final HashMap<String, String> getMetadata()

Returns the metadata for the blob.

final String getName()

Returns the name of the blob.

final CloudBlobDirectory getParent()

Returns the blob item's parent.

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

Retrieves the parent name for a blob URI.

final BlobProperties getProperties()

Returns the blob's properties.

final StorageUri getQualifiedStorageUri()

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

<xreftitle>Deprecated</xreftitle>

<xrefdescription>

  <p>use <xref uid="com.microsoft.azure.storage.blob.CloudBlob.getSnapshotQualifiedStorageUri()" data-throw-if-not-resolved="false" data-raw-source="getSnapshotQualifiedStorageUri()"></xref> instead.</p>

</xrefdescription>

final URI getQualifiedUri()

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

<xreftitle>Deprecated</xreftitle>

<xrefdescription>

  <p>use <xref uid="com.microsoft.azure.storage.blob.CloudBlob.getSnapshotQualifiedUri()" data-throw-if-not-resolved="false" data-raw-source="getSnapshotQualifiedUri()"></xref> instead.</p>

</xrefdescription>

final CloudBlobClient getServiceClient()

Returns the Blob service client associated with the blob.

final String getSnapshotID()

Gets the Blob Snapshot ID.

final StorageUri getSnapshotQualifiedStorageUri()

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

final URI getSnapshotQualifiedUri()

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

final StorageUri getStorageUri()

Returns the list of URIs for all locations.

final int getStreamMinimumReadSizeInBytes()

Returns the minimum read size when using a BlobInputStream.

final int getStreamWriteSizeInBytes()

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

final StorageUri getTransformedAddress(final OperationContext opContext)

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

final URI getUri()

Returns the URI for this blob.

final boolean isSnapshot()

Indicates whether this blob is a snapshot.

final BlobInputStream openInputStream()

Opens a blob input stream to download the blob.

Use setStreamMinimumReadSizeInBytes(final int minimumReadSize) to configure the read size.

final BlobInputStream 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(final int minimumReadSize) to configure the read size.

final BlobInputStream openInputStream(final long offset, final Long length, final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext)

Opens a blob input stream to download the blob using the specified request options and operation context. If the blob is decrypted as it is downloaded, the final MD5 validation will be skipped.

Use setStreamMinimumReadSizeInBytes(final int minimumReadSize) to configure the read size.

final void releaseLease(final AccessCondition accessCondition)

Releases the lease on the blob.

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

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

final void renewLease(final AccessCondition accessCondition)

Renews an existing lease.

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

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

final void setContainer(final CloudBlobContainer container)

Sets the container for the blob.

final void setMetadata(final HashMap<String, String> metadata)

Sets the metadata for the blob.

final void setProperties(final BlobProperties properties)

Sets the properties for the blob.

final void setSnapshotID(final String snapshotID)

Sets the blob snapshot ID.

void setStorageUri(final StorageUri storageUri)

Sets the list of URIs for all locations.

void setStreamMinimumReadSizeInBytes(final int minimumReadSize)

Sets the minimum read size when using a BlobInputStream.

abstract void setStreamWriteSizeInBytes(int streamWriteSizeInBytes)

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

final String startCopy(final URI source)

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

final String 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.

final String startCopy(final URI source, final String blobTierString, 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.

final String startCopy(final URI source, String contentMd5, boolean syncCopy, final String blobTierString, 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.

final String startCopy(final URI source, String contentMd5, boolean syncCopy, final String blobTierString, final RehydratePriority rehydratePriority, 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, rehydrate priority, access conditions, lease ID, request options, and operation context.

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

StorageRequest<CloudBlobClient, CloudBlob, String> startCopyImpl(final URI source, final String contentMd5, final boolean syncCopy, final boolean incrementalCopy, final String blobTierString, final RehydratePriority rehydratePriority, final AccessCondition sourceAccessCondition, final AccessCondition destinationAccessCondition, final BlobRequestOptions options)
final void undelete()

Un-deletes a blob and all its snapshots that have been soft-deleted.

final void undelete(BlobRequestOptions options, OperationContext opContext)

Un-deletes a blob that has been soft-deleted, using the specified request options, and operation context.

The un-delete Blob operation restores the contents and metadata of soft deleted blob and all its snapshots. Attempting to undelete a blob or snapshot that is not soft deleted will succeed without any changes.

void updateEtagAndLastModifiedFromResponse(HttpURLConnection request)
void updateLengthFromResponse(HttpURLConnection request)
abstract void 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.

abstract void 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.

void 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.

void 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.

void uploadFromFile(final String path)

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

void 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.

final void uploadMetadata()

Uploads the blob's metadata to the storage service.

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

final void 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 downloadAttributes() to retrieve the latest values for the blob's properties and metadata from the Microsoft Azure storage service.

final void uploadProperties()

Updates the blob's properties to the storage service.

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

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

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

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

static<T extends CloudBlob, R> void validateCPKHeaders(StorageRequest<CloudBlobClient, T, R> request, BlobRequestOptions options, boolean upload)

If the request options contain a CPK, validate the associated response headers.

Field Details

blobServiceClient

protected CloudBlobClient blobServiceClient

Represents the blob client.

parent

protected CloudBlobDirectory parent

Represents the blob's directory.

streamMinimumReadSizeInBytes

protected int streamMinimumReadSizeInBytes= Constants.DEFAULT_MINIMUM_READ_SIZE_IN_BYTES

Holds the minimum read size when using a BlobInputStream.

streamWriteSizeInBytes

protected int streamWriteSizeInBytes= Constants.DEFAULT_STREAM_WRITE_IN_BYTES

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

Constructor Details

CloudBlob

protected 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.

Parameters:

type - A BlobType value which represents the type of the blob.
uri - A StorageUri object that represents the URI to the blob, beginning with the container name.
snapshotID - A String that represents the snapshot version, if applicable.
credentials - A StorageCredentials object used to authenticate access.

Throws:

StorageException - If a storage service error occurred.

CloudBlob

protected 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.

Parameters:

type - A BlobType value which represents the type of the blob.
blobName - Name of the blob.
snapshotID - A String that represents the snapshot version, if applicable.
container - The reference to the parent container.

Throws:

URISyntaxException - If the resource URI is invalid.

CloudBlob

protected CloudBlob(final CloudBlob otherBlob)

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

Parameters:

otherBlob - A CloudBlob object that represents the blob to copy.

Method Details

abortCopy

public final void abortCopy(final String copyId)

Aborts an ongoing blob copy operation.

Parameters:

copyId - A String object that identifying the copy operation.

Throws:

StorageException - If a storage service error occurred.

abortCopy

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

Aborts an ongoing blob copy operation.

Parameters:

copyId - A String object that identifying the copy operation.
accessCondition - An AccessCondition object that represents the access conditions for the blob.
options - A BlobRequestOptions object that specifies any additional options for the request. Specifying null will use the default request options from the associated service client ( CloudBlobClient).
opContext - An OperationContext object that represents the context for the current operation. This object is used to track requests to the storage service, and to provide additional runtime information about the operation.

Throws:

StorageException - If a storage service error occurred.

acquireLease

public final String acquireLease()

Acquires a new infinite lease on the blob.

Returns:

A String that represents the lease ID.

Throws:

StorageException - If a storage service error occurred.

acquireLease

public final String acquireLease(final Integer leaseTimeInSeconds, final String proposedLeaseId)

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

Parameters:

leaseTimeInSeconds - An Integer which specifies the span of time for which to acquire the lease, in seconds. If null, an infinite lease will be acquired. If not null, the value must be greater than zero.
proposedLeaseId - A String that represents the proposed lease ID for the new lease, or null if no lease ID is proposed.

Returns:

A String that represents the lease ID.

Throws:

StorageException - If a storage service error occurred.

acquireLease

public final String 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.

Parameters:

leaseTimeInSeconds - An Integer which specifies the span of time for which to acquire the lease, in seconds. If null, an infinite lease will be acquired. If not null, the value must be greater than zero.
proposedLeaseId - A String that represents the proposed lease ID for the new lease, or null if no lease ID is proposed.
accessCondition - An AccessCondition object that represents the access conditions for the blob.
options - A BlobRequestOptions object that specifies any additional options for the request. Specifying null will use the default request options from the associated service client (CloudBlobClient).
opContext - An OperationContext object that represents the context for the current operation. The context is used to track requests to the storage service, and to provide additional runtime information about the operation.

Returns:

A String that represents the lease ID.

Throws:

StorageException - If a storage service error occurred.

assertCorrectBlobType

protected final void assertCorrectBlobType()

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

Throws:

StorageException - If an incorrect blob type is used.

assertNoWriteOperationForSnapshot

protected void assertNoWriteOperationForSnapshot()

Asserts that write operation is not done for snapshot.

breakLease

public final long breakLease(final Integer breakPeriodInSeconds)

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

Parameters:

breakPeriodInSeconds - Specifies the time to wait, in seconds, until the current lease is broken. If null, the break period is the remainder of the current lease, or zero for infinite leases.

Returns:

An long which specifies the time, in seconds, remaining in the lease period.

Throws:

StorageException - If a storage service error occurred.

breakLease

public final long 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.

Parameters:

breakPeriodInSeconds - An Integer which specifies the time to wait, in seconds, until the current lease is broken. If null, the break period is the remainder of the current lease, or zero for infinite leases.
accessCondition - An AccessCondition object that represents the access conditions for the blob.
options - A BlobRequestOptions object that specifies any additional options for the request. Specifying null will use the default request options from the associated service client (CloudBlobClient).
opContext - An OperationContext object that represents the context for the current operation. The context is used to track requests to the storage service, and to provide additional runtime information about the operation.

Returns:

An long which represents the time, in seconds, remaining in the lease period.

Throws:

StorageException - If a storage service error occurred.

changeLease

public final String changeLease(final String proposedLeaseId, final AccessCondition accessCondition)

Changes the existing lease ID to the proposed lease ID.

Parameters:

proposedLeaseId - A String that represents the proposed lease ID for the new lease, or null if no lease ID is proposed.
accessCondition - An AccessCondition object that represents the access conditions for the blob. The lease ID is required to be set with an access condition.

Returns:

A String that represents the new lease ID.

Throws:

StorageException - If a storage service error occurred.

changeLease

public final String 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.

Parameters:

proposedLeaseId - A String that represents the proposed lease ID for the new lease, or null if no lease ID is proposed.
accessCondition - An AccessCondition object that represents the access conditions for the blob. The lease ID is required to be set with an access condition.
options - A BlobRequestOptions object that specifies any additional options for the request. Specifying null will use the default request options from the associated service client (CloudBlobClient).
opContext - An OperationContext object that represents the context for the current operation. The context is used to track requests to the storage service, and to provide additional runtime information about the operation.

Returns:

A String that represents the new lease ID.

Throws:

StorageException - If a storage service error occurred.

createSnapshot

public final CloudBlob createSnapshot()

Creates a snapshot of the blob.

Returns:

A CloudBlob object that represents the snapshot of the blob.

Throws:

StorageException - If a storage service error occurred.

createSnapshot

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

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

Parameters:

accessCondition - An AccessCondition object that represents the access conditions for the blob.
options - A BlobRequestOptions object that specifies any additional options for the request. Specifying null will use the default request options from the associated service client ( CloudBlobClient).
opContext - An OperationContext object that represents the context for the current operation. This object is used to track requests to the storage service, and to provide additional runtime information about the operation.

Returns:

A CloudBlob object that represents the snapshot of the blob.

Throws:

StorageException - If a storage service error occurred.

createSnapshot

public final CloudBlob createSnapshot(final HashMap metadata, final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext)

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

Parameters:

metadata - A collection of name-value pairs defining the metadata of the snapshot, or null.
accessCondition - An AccessCondition object that represents the access conditions for the blob.
options - A BlobRequestOptions object that specifies any additional options for the request. Specifying null will use the default request options from the associated service client ( CloudBlobClient).
opContext - An OperationContext object that represents the context for the current operation. This object is used to track requests to the storage service, and to provide additional runtime information about the operation.

Returns:

A CloudBlob object that represents the snapshot of the blob.

Throws:

StorageException - If a storage service error occurred.

delete

public final void delete()

Deletes the blob.

If a delete retention policy is enabled on the service, the blob will be retained for a specified period of time, before being removed permanently by garbage collection.

Throws:

StorageException - If a storage service error occurred.

delete

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

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

If a delete retention policy is enabled on the service, the blob will be retained for a specified period of time, before being removed permanently by garbage collection.

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

Parameters:

deleteSnapshotsOption - A DeleteSnapshotsOption object that indicates whether to delete only snapshots, or the blob and its snapshots.
accessCondition - An AccessCondition object that represents the access conditions for the blob.
options - A BlobRequestOptions object that specifies any additional options for the request. Specifying null will use the default request options from the associated service client ( CloudBlobClient).
opContext - An OperationContext object that represents the context for the current operation. This object is used to track requests to the storage service, and to provide additional runtime information about the operation.

Throws:

StorageException - If a storage service error occurred.

deleteIfExists

public final boolean 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 DELETE_SNAPSHOTS_ONLY or INCLUDE_SNAPSHOTS value in the parameter to specify how the snapshots should be handled when the blob is deleted.

Returns:

true if the blob was deleted; otherwise, false.

Throws:

StorageException - If a storage service error occurred.

deleteIfExists

public final boolean 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 DELETE_SNAPSHOTS_ONLY or INCLUDE_SNAPSHOTS value in the parameter to specify how the snapshots should be handled when the blob is deleted.

Parameters:

deleteSnapshotsOption - A DeleteSnapshotsOption object that indicates whether to delete only snapshots, or the blob and its snapshots.
accessCondition - An AccessCondition object that represents the access conditions for the blob.
options - A BlobRequestOptions object that specifies any additional options for the request. Specifying null will use the default request options from the associated service client ( CloudBlobClient).
opContext - An OperationContext object that represents the context for the current operation. This object is used to track requests to the storage service, and to provide additional runtime information about the operation.

Returns:

true if the blob existed and was deleted; otherwise, false

Throws:

StorageException - If a storage service error occurred.

download

public final void download(final OutputStream outStream)

Downloads the contents of a blob to a stream.

Parameters:

outStream - An OutputStream object that represents the target stream.

Throws:

StorageException - If a storage service error occurred.

download

public final void 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.

Parameters:

outStream - An OutputStream object that represents the target stream.
accessCondition - An AccessCondition object that represents the access conditions for the blob.
options - A BlobRequestOptions object that specifies any additional options for the request. Specifying null will use the default request options from the associated service client ( CloudBlobClient).
opContext - An OperationContext object that represents the context for the current operation. This object is used to track requests to the storage service, and to provide additional runtime information about the operation.

Throws:

StorageException - If a storage service error occurred.

downloadAccountInfo

public AccountInformation downloadAccountInfo()

Gets information related to the storage account in which this blob resides.

Returns:

A AccountInformation object for the given storage account.

Throws:

StorageException - If a storage service error occurred.

downloadAccountInfo

public AccountInformation downloadAccountInfo(BlobRequestOptions options, OperationContext opContext)

Gets information related to the storage account in which this blob resides.

Parameters:

options - A BlobRequestOptions object that specifies any additional options for the request. Specifying null will use the default request options from the associated service client ( CloudBlobClient).
opContext - An OperationContext object that represents the context for the current operation. This object is used to track requests to the storage service, and to provide additional runtime information about the operation.

Returns:

A AccountInformation object for the given storage account.

Throws:

StorageException - If a storage service error occurred.

downloadAccountInformationImpl

protected StorageRequest downloadAccountInformationImpl(final RequestOptions options)

Parameters:

options

downloadAttributes

public final void 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.

Throws:

StorageException - If a storage service error occurred.

downloadAttributes

public final void 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.

Parameters:

accessCondition - An AccessCondition object that represents the access conditions for the blob.
options - A BlobRequestOptions object that specifies any additional options for the request. Specifying null will use the default request options from the associated service client ( CloudBlobClient).
opContext - An OperationContext object that represents the context for the current operation. This object is used to track requests to the storage service, and to provide additional runtime information about the operation.

Throws:

StorageException - If a storage service error occurred.

downloadRange

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

Downloads the contents of a blob to a stream.

Parameters:

offset - A long which represents the offset to use as the starting point for the source.
length - A Long which represents the number of bytes to read or null.
outStream - An OutputStream object that represents the target stream.

Throws:

StorageException - If a storage service error occurred.

downloadRange

public final void 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.

Parameters:

offset - A long which represents the offset to use as the starting point for the source.
length - A Long which represents the number of bytes to read or null.
outStream - An OutputStream object that represents the target stream.
accessCondition - An AccessCondition object that represents the access conditions for the blob.
options - A BlobRequestOptions object that specifies any additional options for the request. Specifying null will use the default request options from the associated service client ( CloudBlobClient).
opContext - An OperationContext object that represents the context for the current operation. This object is used to track requests to the storage service, and to provide additional runtime information about the operation.

Throws:

StorageException - If a storage service error occurred.

downloadRangeInternal

protected final int 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.

Parameters:

blobOffset - A long which represents the offset within the blob to begin downloading.
length - A Long which represents the number of bytes to read.
buffer - A byte array which represents the buffer to write to.
bufferOffset - An int which represents the offset in the byte buffer to begin writing.
accessCondition - An AccessCondition object that represents the access conditions for the blob.
options - A BlobRequestOptions object that specifies any additional options for the request.
opContext - An OperationContext object used to track the execution of the operation.

Returns:

The total number of bytes read into the buffer.

Throws:

StorageException - an exception representing any error which occurred during the operation.

downloadRangeToByteArray

public final int 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.

Parameters:

offset - A long which represents the byte offset to use as the starting point for the source.
length - A Long which represents the number of bytes to read or null.
buffer - A byte array which represents the buffer to which the blob bytes are downloaded.
bufferOffset - An int which represents the byte offset to use as the starting point for the target.

Returns:

The total number of bytes read into the buffer.

Throws:

StorageException

downloadRangeToByteArray

public final int 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.

Parameters:

offset - A long which represents the byte offset to use as the starting point for the source.
length - A Long which represents the number of bytes to read or null.
buffer - A byte array which represents the buffer to which the blob bytes are downloaded.
bufferOffset - An int which represents the byte offset to use as the starting point for the target.
accessCondition - An AccessCondition object that represents the access conditions for the blob.
options - A BlobRequestOptions object that specifies any additional options for the request. Specifying null will use the default request options from the associated service client ( CloudBlobClient).
opContext - An OperationContext object that represents the context for the current operation. This object is used to track requests to the storage service, and to provide additional runtime information about the operation.

Returns:

The total number of bytes read into the buffer.

Throws:

StorageException - If a storage service error occurred.

downloadToByteArray

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

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

Parameters:

buffer - A byte array which represents the buffer to which the blob bytes are downloaded.
bufferOffset - An int which represents the byte offset to use as the starting point for the target.

Throws:

StorageException - If a storage service error occurred.

downloadToByteArray

public final int 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.

Parameters:

buffer - A byte array which represents the buffer to which the blob bytes are downloaded.
bufferOffset - A long which represents the byte offset to use as the starting point for the target.
accessCondition - An AccessCondition object that represents the access conditions for the blob.
options - A BlobRequestOptions object that specifies any additional options for the request. Specifying null will use the default request options from the associated service client ( CloudBlobClient).
opContext - An OperationContext object that represents the context for the current operation. This object is used to track requests to the storage service, and to provide additional runtime information about the operation.

Throws:

StorageException - If a storage service error occurred.

downloadToFile

public void downloadToFile(final String path)

Downloads a blob, storing the contents in a file.

Parameters:

path - A String which represents the path to the file that will be created with the contents of the blob.

Throws:

StorageException - If a storage service error occurred.
IOException

downloadToFile

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

Downloads a blob, storing the contents in a file.

Parameters:

path - A String which represents the path to the file that will be created with the contents of the blob.
accessCondition - An AccessCondition object that represents the access conditions for the blob.
options - A BlobRequestOptions object that specifies any additional options for the request. Specifying null will use the default request options from the associated service client ( CloudBlobClient).
opContext - An OperationContext object that represents the context for the current operation. This object is used to track requests to the storage service, and to provide additional runtime information about the operation.

Throws:

StorageException - If a storage service error occurred.
IOException

exists

public final boolean exists()

Checks to see if the blob exists.

Returns:

true if the blob exists, otherwise false.

Throws:

StorageException - If a storage service error occurred.

exists

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

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

Parameters:

accessCondition - An AccessCondition object that represents the access conditions for the blob.
options - A BlobRequestOptions object that specifies any additional options for the request. Specifying null will use the default request options from the associated service client ( CloudBlobClient).
opContext - An OperationContext object that represents the context for the current operation. This object is used to track requests to the storage service, and to provide additional runtime information about the operation.

Returns:

true if the blob exists, other wise false.

Throws:

StorageException - If a storage service error occurred.

generateSharedAccessSignature

public String 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 "?".

Parameters:

policy - A SharedAccessPolicy object that represents the access policy for the shared access signature.
headers - A SharedAccessBlobHeaders object that represents the optional header values to set for a blob accessed with this shared access signature.
groupPolicyIdentifier - A String that represents the container-level access policy.

Returns:

A String that represents the shared access signature.

Throws:

IllegalArgumentException - If the credentials are invalid or the blob is a snapshot.
InvalidKeyException - If the credentials are invalid.
StorageException - If a storage service error occurred.

generateSharedAccessSignature

public String 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 "?".

Parameters:

policy - A SharedAccessPolicy object that represents the access policy for the shared access signature.
headers - A SharedAccessBlobHeaders object that represents the optional header values to set for a blob accessed with this shared access signature.
groupPolicyIdentifier - A String that represents the container-level access policy.
ipRange - A IPRange object containing the range of allowed IP addresses.
protocols - A SharedAccessProtocols representing the allowed Internet protocols.

Returns:

A String that represents the shared access signature.

Throws:

IllegalArgumentException - If the credentials are invalid or the blob is a snapshot.
InvalidKeyException - If the credentials are invalid.
StorageException - If a storage service error occurred.

generateSharedAccessSignature

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

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

Parameters:

policy - A SharedAccessPolicy object that represents the access policy for the shared access signature.
headers - A SharedAccessBlobHeaders object that represents the optional header values to set for a blob accessed with this shared access signature.
groupPolicyIdentifier - A String that represents the container-level access policy.
ipRange - A IPRange object containing the range of allowed IP addresses.
protocols - A SharedAccessProtocols representing the allowed Internet protocols.
skipDecoding - A boolean to indicate that the query parameters should not be decoded before being signed. This should only be used if the customer is sure the values passed are in the desired format. This may be useful in some scenarios where the client is used to generate a sas to a third party that will not be using this sdk to make the requests.

Returns:

A String that represents the shared access signature.

Throws:

IllegalArgumentException - If the credentials are invalid or the blob is a snapshot.
InvalidKeyException - If the credentials are invalid.
StorageException - If a storage service error occurred.

generateSharedAccessSignature

public String 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 "?".

Parameters:

policy - A SharedAccessPolicy object that represents the access policy for the shared access signature.
groupPolicyIdentifier - A String that represents the container-level access policy.

Returns:

A String that represents the shared access signature.

Throws:

IllegalArgumentException - If the credentials are invalid or the blob is a snapshot.
InvalidKeyException - If the credentials are invalid.
StorageException - If a storage service error occurred.

generateUserDelegationSharedAccessSignature

public String generateUserDelegationSharedAccessSignature(final UserDelegationKey delegationKey, final SharedAccessBlobPolicy policy, final SharedAccessBlobHeaders headers, final IPRange ipRange, final SharedAccessProtocols protocols)

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

Parameters:

delegationKey - A UserDelegationKey representing the key used to sign this signature.
policy - A SharedAccessPolicy object that represents the access policy for the shared access signature.
headers - A SharedAccessBlobHeaders object that represents the optional header values to set for a blob accessed with this shared access signature.
ipRange - A IPRange object containing the range of allowed IP addresses.
protocols - A SharedAccessProtocols representing the allowed Internet protocols.

Returns:

A String that represents the shared access signature.

Throws:

StorageException - If a storage service error occurred.

generateUserDelegationSharedAccessSignature

public String generateUserDelegationSharedAccessSignature(UserDelegationKey delegationKey, SharedAccessBlobPolicy policy)

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

Parameters:

delegationKey - A UserDelegationKey representing the key used to sign this signature.
policy - A SharedAccessPolicy object that represents the access policy for the shared access signature.

Returns:

A String that represents the shared access signature.

Throws:

StorageException - If a storage service error occurred.

getContainer

public final CloudBlobContainer getContainer()

Returns the blob's container.

Overrides:

CloudBlob.getContainer()

Returns:

A CloudBlobContainer object that represents the container of the blob.

Throws:

StorageException - If a storage service error occurred.
URISyntaxException - If the resource URI is invalid.

getCopyState

public CopyState getCopyState()

Returns the blob's copy state.

Returns:

A CopyState object that represents the copy state of the blob.

getMetadata

public final HashMap getMetadata()

Returns the metadata for the blob.

Returns:

A java.util.HashMap object that represents the metadata for the blob.

getName

public final String getName()

Returns the name of the blob.

Returns:

A String that represents the name of the blob.

getParent

public final CloudBlobDirectory getParent()

Returns the blob item's parent.

Overrides:

CloudBlob.getParent()

Returns:

A CloudBlobDirectory object that represents the parent directory for the blob.

Throws:

StorageException - If a storage service error occurred.
URISyntaxException - If the resource URI is invalid.

getParentNameFromURI

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

Retrieves the parent name for a blob URI.

Parameters:

resourceAddress - A StorageUri object which represents the resource URI.
delimiter - A String which specifies the directory delimiter to use.
container - A CloudBlobContainer object which represents the blob container.

Returns:

A String which represents the parent address for a blob URI.

Throws:

URISyntaxException

getProperties

public final BlobProperties getProperties()

Returns the blob's properties.

Returns:

A BlobProperties object that represents the properties of the blob.

getQualifiedStorageUri

public final StorageUri getQualifiedStorageUri()

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

<xreftitle>Deprecated</xreftitle>

<xrefdescription>

  <p>use <xref uid="com.microsoft.azure.storage.blob.CloudBlob.getSnapshotQualifiedStorageUri()" data-throw-if-not-resolved="false" data-raw-source="getSnapshotQualifiedStorageUri()"></xref> instead.</p>

</xrefdescription>

Returns:

A StorageUri object that represents the snapshot or shared access signature.

Throws:

StorageException - If a storage service error occurred.
URISyntaxException - If the resource URI is invalid.

getQualifiedUri

public final URI getQualifiedUri()

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

<xreftitle>Deprecated</xreftitle>

<xrefdescription>

  <p>use <xref uid="com.microsoft.azure.storage.blob.CloudBlob.getSnapshotQualifiedUri()" data-throw-if-not-resolved="false" data-raw-source="getSnapshotQualifiedUri()"></xref> instead.</p>

</xrefdescription>

Returns:

A java.net.URI object that represents the snapshot or shared access signature.

Throws:

StorageException - If a storage service error occurred.
URISyntaxException - If the resource URI is invalid.

getServiceClient

public final CloudBlobClient getServiceClient()

Returns the Blob service client associated with the blob.

Returns:

A CloudBlobClient object that represents the client.

getSnapshotID

public final String getSnapshotID()

Gets the Blob Snapshot ID.

Returns:

A String which represents the Blob Snapshot ID.

getSnapshotQualifiedStorageUri

public final StorageUri getSnapshotQualifiedStorageUri()

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

Returns:

A StorageUri object containing the blob's URIs for both the primary and secondary locations, including snapshot query information if the blob is a snapshot.

Throws:

StorageException - If a storage service error occurred.
URISyntaxException - If the resource URI is invalid.

getSnapshotQualifiedUri

public final URI getSnapshotQualifiedUri()

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

Returns:

A java.net.URI object specifying the absolute URI to the blob, including snapshot query information if the blob is a snapshot.

Throws:

StorageException - If a storage service error occurred.
URISyntaxException - If the resource URI is invalid.

getStorageUri

public final StorageUri getStorageUri()

Returns the list of URIs for all locations.

Overrides:

CloudBlob.getStorageUri()

Returns:

A StorageUri that represents the list of URIs for all locations..

getStreamMinimumReadSizeInBytes

public final int getStreamMinimumReadSizeInBytes()

Returns the minimum read size when using a BlobInputStream.

Returns:

A int which represents the minimum read size, in bytes, when using a BlobInputStream object.

getStreamWriteSizeInBytes

public final int getStreamWriteSizeInBytes()

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

Returns:

A int which represents the number of bytes to buffer or the size of a block, in bytes.

getTransformedAddress

protected final StorageUri getTransformedAddress(final OperationContext opContext)

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

Parameters:

opContext - An OperationContext object that represents the context for the current operation. This object is used to track requests to the storage service, and to provide additional runtime information about the operation.

Returns:

A StorageUri object that represents the transformed URI.

Throws:

IllegalArgumentException - If the URI is not absolute.
StorageException - If a storage service error occurred.
URISyntaxException - If the resource URI is invalid.

getUri

public final URI getUri()

Returns the URI for this blob.

Overrides:

CloudBlob.getUri()

Returns:

A java.net.URI object that represents the URI for the blob.

isSnapshot

public final boolean isSnapshot()

Indicates whether this blob is a snapshot.

Returns:

true if the blob is a snapshot, otherwise false.

openInputStream

public final BlobInputStream openInputStream()

Opens a blob input stream to download the blob.

Use setStreamMinimumReadSizeInBytes(final int minimumReadSize) to configure the read size.

Returns:

An InputStream object that represents the stream to use for reading from the blob.

Throws:

StorageException - If a storage service error occurred.

openInputStream

public final BlobInputStream 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(final int minimumReadSize) to configure the read size.

Parameters:

accessCondition - An AccessCondition object that represents the access conditions for the blob.
options - A BlobRequestOptions object that specifies any additional options for the request. Specifying null will use the default request options from the associated service client ( CloudBlobClient).
opContext - An OperationContext object that represents the context for the current operation. This object is used to track requests to the storage service, and to provide additional runtime information about the operation.

Returns:

An InputStream object that represents the stream to use for reading from the blob.

Throws:

StorageException - If a storage service error occurred.

openInputStream

public final BlobInputStream openInputStream(final long offset, final Long length, final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext)

Opens a blob input stream to download the blob using the specified request options and operation context. If the blob is decrypted as it is downloaded, the final MD5 validation will be skipped.

Use setStreamMinimumReadSizeInBytes(final int minimumReadSize) to configure the read size.

Parameters:

offset - A long which represents the offset to use as the starting point for the source.
length - A Long which represents the number of bytes to read or null.
accessCondition - An AccessCondition object that represents the access conditions for the blob.
options - A BlobRequestOptions object that specifies any additional options for the request. Specifying null will use the default request options from the associated service client ( CloudBlobClient).
opContext - An OperationContext object that represents the context for the current operation. This object is used to track requests to the storage service, and to provide additional runtime information about the operation.

Returns:

An InputStream object that represents the stream to use for reading from the blob.

Throws:

StorageException - If a storage service error occurred.

releaseLease

public final void releaseLease(final AccessCondition accessCondition)

Releases the lease on the blob.

Parameters:

accessCondition - An AccessCondition object that represents the access conditions for the blob. The LeaseID is required to be set on the AccessCondition.

Throws:

StorageException - If a storage service error occurred.

releaseLease

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

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

Parameters:

accessCondition - An AccessCondition object that represents the access conditions for the blob.The LeaseID is required to be set on the AccessCondition.
options - A BlobRequestOptions object that specifies any additional options for the request. Specifying null will use the default request options from the associated service client ( CloudBlobClient).
opContext - An OperationContext object that represents the context for the current operation. This object is used to track requests to the storage service, and to provide additional runtime information about the operation.

Throws:

StorageException - If a storage service error occurred.

renewLease

public final void renewLease(final AccessCondition accessCondition)

Renews an existing lease.

Parameters:

accessCondition - An AccessCondition object that represents the access conditions for the blob. The LeaseID is required to be set on the AccessCondition.

Throws:

StorageException - If a storage service error occurred.

renewLease

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

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

Parameters:

accessCondition - An AccessCondition object that represents the access conditions for the blob. The LeaseID is required to be set on the AccessCondition.
options - A BlobRequestOptions object that specifies any additional options for the request. Specifying null will use the default request options from the associated service client ( CloudBlobClient).
opContext - An OperationContext object that represents the context for the current operation. This object is used to track requests to the storage service, and to provide additional runtime information about the operation.

Throws:

StorageException - If a storage service error occurred.

setContainer

protected final void setContainer(final CloudBlobContainer container)

Sets the container for the blob.

Parameters:

container - A CloudBlobContainer object that represents the container being assigned to the blob.

setMetadata

public final void setMetadata(final HashMap metadata)

Sets the metadata for the blob.

Parameters:

metadata - A java.util.HashMap object that contains the metadata being assigned to the blob.

setProperties

protected final void setProperties(final BlobProperties properties)

Sets the properties for the blob.

Parameters:

properties - A BlobProperties object that represents the properties being assigned to the blob.

setSnapshotID

protected final void setSnapshotID(final String snapshotID)

Sets the blob snapshot ID.

Parameters:

snapshotID - A String that represents the snapshot ID being assigned to the blob.

setStorageUri

protected void setStorageUri(final StorageUri storageUri)

Sets the list of URIs for all locations.

Parameters:

storageUri - A StorageUri that represents the list of URIs for all locations.

setStreamMinimumReadSizeInBytes

public void setStreamMinimumReadSizeInBytes(final int minimumReadSize)

Sets the minimum read size when using a BlobInputStream.

Parameters:

minimumReadSize - An int that represents the minimum block size, in bytes, for reading from a blob while using a BlobInputStream object. Must be greater than or equal to 16 KB.

Throws:

IllegalArgumentException - If minimumReadSize is less than 16 KB.

setStreamWriteSizeInBytes

public abstract void setStreamWriteSizeInBytes(int streamWriteSizeInBytes)

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

Parameters:

streamWriteSizeInBytes - An int that represents the number of bytes to buffer or the size of a block, in bytes.

startCopy

public final String startCopy(final URI source)

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

Parameters:

source - A java.net.URI The source URI. URIs for resources outside of Azure may only be copied into block blobs.

Returns:

A String which represents the copy ID associated with the copy operation.

Throws:

StorageException - If a storage service error occurred.

startCopy

public final String 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.

Parameters:

source - A java.net.URI The source URI. URIs for resources outside of Azure may only be copied into block blobs.
sourceAccessCondition - An AccessCondition object that represents the access conditions for the source.
destinationAccessCondition - An AccessCondition object that represents the access conditions for the destination.
options - A BlobRequestOptions object that specifies any additional options for the request. Specifying null will use the default request options from the associated service client (CloudBlobClient).
opContext - An OperationContext object that represents the context for the current operation. This object is used to track requests to the storage service, and to provide additional runtime information about the operation.

Returns:

A String which represents the copy ID associated with the copy operation.

Throws:

StorageException - If a storage service error occurred.

startCopy

protected final String startCopy(final URI source, final String blobTierString, 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.

Parameters:

source - A java.net.URI The source URI. URIs for resources outside of Azure may only be copied into block blobs.
blobTierString - A String which represents the tier of the blob.
sourceAccessCondition - An AccessCondition object that represents the access conditions for the source.
destinationAccessCondition - An AccessCondition object that represents the access conditions for the destination.
options - A BlobRequestOptions object that specifies any additional options for the request. Specifying null will use the default request options from the associated service client (CloudBlobClient).
opContext - An OperationContext object that represents the context for the current operation. This object is used to track requests to the storage service, and to provide additional runtime information about the operation.

Returns:

A String which represents the copy ID associated with the copy operation.

Throws:

StorageException - If a storage service error occurred.

startCopy

protected final String startCopy(final URI source, String contentMd5, boolean syncCopy, final String blobTierString, 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.

Parameters:

source - A java.net.URI The source URI. URIs for resources outside of Azure may only be copied into block blobs.
contentMd5 - An optional hash value used to ensure transactional integrity for the operation. May be null or empty.
syncCopy - A boolean which indicates if the copy should be done synchronously on the service.
blobTierString - A String which represents the tier of the blob.
sourceAccessCondition - An AccessCondition object that represents the access conditions for the source.
destinationAccessCondition - An AccessCondition object that represents the access conditions for the destination.
options - A BlobRequestOptions object that specifies any additional options for the request. Specifying null will use the default request options from the associated service client (CloudBlobClient).
opContext - An OperationContext object that represents the context for the current operation. This object is used to track requests to the storage service, and to provide additional runtime information about the operation.

Returns:

A String which represents the copy ID associated with the copy operation.

Throws:

StorageException - If a storage service error occurred.

startCopy

protected final String startCopy(final URI source, String contentMd5, boolean syncCopy, final String blobTierString, final RehydratePriority rehydratePriority, 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, rehydrate priority, access conditions, lease ID, request options, and operation context.

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

Parameters:

source - A java.net.URI The source URI. URIs for resources outside of Azure may only be copied into block blobs.
contentMd5 - An optional hash value used to ensure transactional integrity for the operation. May be null or empty.
syncCopy - A boolean which indicates if the copy should be done synchronously on the service.
blobTierString - A String object which represents the tier of the blob.
rehydratePriority - A RehydratePriority object which represents the rehydrate priority.
sourceAccessCondition - An AccessCondition object that represents the access conditions for the source.
destinationAccessCondition - An AccessCondition object that represents the access conditions for the destination.
options - A BlobRequestOptions object that specifies any additional options for the request. Specifying null will use the default request options from the associated service client (CloudBlobClient).
opContext - An OperationContext object that represents the context for the current operation. This object is used to track requests to the storage service, and to provide additional runtime information about the operation.

Returns:

A String which represents the copy ID associated with the copy operation.

Throws:

StorageException - If a storage service error occurred.

startCopyImpl

protected StorageRequest startCopyImpl(final URI source, final String contentMd5, final boolean syncCopy, final boolean incrementalCopy, final String blobTierString, final RehydratePriority rehydratePriority, final AccessCondition sourceAccessCondition, final AccessCondition destinationAccessCondition, final BlobRequestOptions options)

Parameters:

source
contentMd5
syncCopy
incrementalCopy
blobTierString
rehydratePriority
sourceAccessCondition
destinationAccessCondition
options

undelete

public final void undelete()

Un-deletes a blob and all its snapshots that have been soft-deleted.

Throws:

StorageException - If a storage service error occurred.

undelete

public final void undelete(BlobRequestOptions options, OperationContext opContext)

Un-deletes a blob that has been soft-deleted, using the specified request options, and operation context.

The un-delete Blob operation restores the contents and metadata of soft deleted blob and all its snapshots. Attempting to undelete a blob or snapshot that is not soft deleted will succeed without any changes.

Parameters:

options - A BlobRequestOptions object that specifies any additional options for the request. Specifying null will use the default request options from the associated service client ( CloudBlobClient).
opContext - An OperationContext object that represents the context for the current operation. This object is used to track requests to the storage service, and to provide additional runtime information about the operation.

Throws:

StorageException - If a storage service error occurred.

updateEtagAndLastModifiedFromResponse

protected void updateEtagAndLastModifiedFromResponse(HttpURLConnection request)

Parameters:

request

updateLengthFromResponse

protected void updateLengthFromResponse(HttpURLConnection request)

Parameters:

request

upload

public abstract void 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.

Parameters:

sourceStream - An InputStream object that represents the source stream to upload.
length - An long that represents the length of the stream data in bytes, or -1 if unknown. The length must be greater than zero and a multiple of 512 for page blobs.

Throws:

IOException - If an I/O exception occurred.
StorageException - If a storage service error occurred.

upload

public abstract void 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.

Parameters:

sourceStream - An InputStream object that represents the source stream to upload.
length - The length of the stream data in bytes, or -1 if unknown. The length must be greater than zero and a multiple of 512 for page blobs.
accessCondition - An AccessCondition object that represents the access conditions for the blob.
options - A BlobRequestOptions object that specifies any additional options for the request. Specifying null will use the default request options from the associated service client ( CloudBlobClient).
opContext - An OperationContext object that represents the context for the current operation. This object is used to track requests to the storage service, and to provide additional runtime information about the operation.

Throws:

IOException - If an I/O exception occurred.
StorageException - If a storage service error occurred.

uploadFromByteArray

public void 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.

Parameters:

buffer - A byte array which represents the data to write to the blob.
offset - A int which represents the offset of the byte array from which to start the data upload.
length - An int which represents the number of bytes to upload from the input buffer.

Throws:

StorageException - If a storage service error occurred.
IOException

uploadFromByteArray

public void 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.

Parameters:

buffer - A byte array which represents the data to write to the blob.
offset - A int which represents the offset of the byte array from which to start the data upload.
length - An int which represents the number of bytes to upload from the input buffer.
accessCondition - An AccessCondition object that represents the access conditions for the blob.
options - A BlobRequestOptions object that specifies any additional options for the request. Specifying null will use the default request options from the associated service client ( CloudBlobClient).
opContext - An OperationContext object that represents the context for the current operation. This object is used to track requests to the storage service, and to provide additional runtime information about the operation.

Throws:

StorageException - If a storage service error occurred.
IOException

uploadFromFile

public void uploadFromFile(final String path)

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

Parameters:

path - A String which represents the path to the file to be uploaded.

Throws:

StorageException - If a storage service error occurred.
IOException

uploadFromFile

public void 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.

Parameters:

path - A String which represents the path to the file to be uploaded.
accessCondition - An AccessCondition object that represents the access conditions for the blob.
options - A BlobRequestOptions object that specifies any additional options for the request. Specifying null will use the default request options from the associated service client ( CloudBlobClient).
opContext - An OperationContext object that represents the context for the current operation. This object is used to track requests to the storage service, and to provide additional runtime information about the operation.

Throws:

StorageException - If a storage service error occurred.
IOException

uploadMetadata

public final void uploadMetadata()

Uploads the blob's metadata to the storage service.

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

Throws:

StorageException - If a storage service error occurred.

uploadMetadata

public final void 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 downloadAttributes() to retrieve the latest values for the blob's properties and metadata from the Microsoft Azure storage service.

Parameters:

accessCondition - An AccessCondition object that represents the access conditions for the blob.
options - A BlobRequestOptions object that specifies any additional options for the request. Specifying null will use the default request options from the associated service client ( CloudBlobClient).
opContext - An OperationContext object that represents the context for the current operation. This object is used to track requests to the storage service, and to provide additional runtime information about the operation.

Throws:

StorageException - If a storage service error occurred.

uploadProperties

public final void uploadProperties()

Updates the blob's properties to the storage service.

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

Throws:

StorageException - If a storage service error occurred.

uploadProperties

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

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

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

Parameters:

accessCondition - An AccessCondition object that represents the access conditions for the blob.
options - A BlobRequestOptions object that specifies any additional options for the request. Specifying null will use the default request options from the associated service client ( CloudBlobClient).
opContext - An OperationContext object that represents the context for the current operation. This object is used to track requests to the storage service, and to provide additional runtime information about the operation.

Throws:

StorageException - If a storage service error occurred.

validateCPKHeaders

protected static static void validateCPKHeaders(StorageRequest request, BlobRequestOptions options, boolean upload)

If the request options contain a CPK, validate the associated response headers.

Parameters:

request - The storage request to check the response of.
options - The blob options used on the request.
upload - Whether this was an upload or if we're just retrieving data.

Throws:

StorageException - Throws if CPK was used in the request and the response failed validation.

Applies to