public abstract class CloudBlob extends Object implements ListBlobItem
CloudBlockBlob and CloudPageBlob
classes.| Modifier and Type | Field and Description |
|---|---|
protected CloudBlobClient |
blobServiceClient
Represents the blob client.
|
protected CloudBlobDirectory |
parent
Represents the blob's directory.
|
protected int |
streamMinimumReadSizeInBytes
Holds the minimum read size when using a
BlobInputStream. |
protected int |
streamWriteSizeInBytes
Holds the number of bytes to buffer when writing to a
BlobOutputStream (block and page blobs). |
| Modifier | Constructor and Description |
|---|---|
protected |
CloudBlob(BlobType type)
Creates an instance of the
CloudBlob class. |
protected |
CloudBlob(BlobType type,
StorageUri uri,
CloudBlobClient client)
Creates an instance of the
CloudBlob class using the specified URI and cloud blob client. |
protected |
CloudBlob(BlobType type,
StorageUri uri,
CloudBlobClient client,
CloudBlobContainer container)
Creates an instance of the
CloudBlob class using the specified URI, cloud blob client, and cloud
blob container. |
protected |
CloudBlob(BlobType type,
StorageUri uri,
String snapshotID,
CloudBlobClient client)
Creates an instance of the
CloudBlob class using the specified URI, snapshot ID, and cloud blob
client. |
protected |
CloudBlob(CloudBlob otherBlob)
Creates an instance of the
CloudBlob class by copying values from another blob. |
| Modifier and Type | Method and Description |
|---|---|
void |
abortCopy(String copyId)
Aborts an ongoing blob copy operation.
|
void |
abortCopy(String copyId,
AccessCondition accessCondition,
BlobRequestOptions options,
OperationContext opContext)
Aborts an ongoing blob copy operation.
|
String |
acquireLease(Integer leaseTimeInSeconds,
String proposedLeaseId)
Acquires a new lease on the blob with the specified lease time and proposed lease ID.
|
String |
acquireLease(Integer leaseTimeInSeconds,
String proposedLeaseId,
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.
|
protected void |
assertCorrectBlobType()
Asserts that the blob has the correct blob type specified in the blob attributes.
|
protected void |
assertNoWriteOperationForSnapshot()
Asserts that write operation is not done for snapshot.
|
long |
breakLease(Integer breakPeriodInSeconds)
Breaks the lease and ensures that another client cannot acquire a new lease until the current lease period
has expired.
|
long |
breakLease(Integer breakPeriodInSeconds,
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.
|
String |
changeLease(String proposedLeaseId,
AccessCondition accessCondition)
Changes the existing lease ID to the proposed lease ID.
|
String |
changeLease(String proposedLeaseId,
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.
|
CloudBlob |
createSnapshot()
Creates a snapshot of the blob.
|
CloudBlob |
createSnapshot(AccessCondition accessCondition,
BlobRequestOptions options,
OperationContext opContext)
Creates a snapshot of the blob using the specified request options and operation context.
|
CloudBlob |
createSnapshot(HashMap<String,String> metadata,
AccessCondition accessCondition,
BlobRequestOptions options,
OperationContext opContext)
Creates a snapshot of the blob using the specified request options and operation context.
|
void |
delete()
Deletes the blob.
|
void |
delete(DeleteSnapshotsOption deleteSnapshotsOption,
AccessCondition accessCondition,
BlobRequestOptions options,
OperationContext opContext)
Deletes the blob using the specified snapshot and request options, and operation context.
|
boolean |
deleteIfExists()
Deletes the blob if it exists.
|
boolean |
deleteIfExists(DeleteSnapshotsOption deleteSnapshotsOption,
AccessCondition accessCondition,
BlobRequestOptions options,
OperationContext opContext)
Deletes the blob if it exists, using the specified snapshot and request options, and operation context.
|
void |
download(OutputStream outStream)
Downloads the contents of a blob to a stream.
|
void |
download(OutputStream outStream,
AccessCondition accessCondition,
BlobRequestOptions options,
OperationContext opContext)
Downloads the contents of a blob to a stream using the specified request options and operation context.
|
void |
downloadAttributes()
Populates a blob's properties and metadata.
|
void |
downloadAttributes(AccessCondition accessCondition,
BlobRequestOptions options,
OperationContext opContext)
Populates a blob's properties and metadata using the specified request options and operation context.
|
void |
downloadRange(long offset,
Long length,
OutputStream outStream)
Downloads the contents of a blob to a stream.
|
void |
downloadRange(long offset,
Long length,
OutputStream outStream,
AccessCondition accessCondition,
BlobRequestOptions options,
OperationContext opContext)
Downloads the contents of a blob to a stream using the specified request options and operation context.
|
protected int |
downloadRangeInternal(long blobOffset,
Long length,
byte[] buffer,
int bufferOffset,
AccessCondition accessCondition,
BlobRequestOptions options,
OperationContext opContext)
Downloads a range of bytes from the blob to the given byte buffer.
|
int |
downloadRangeToByteArray(long offset,
Long length,
byte[] buffer,
int bufferOffet)
Downloads a range of bytes from the blob to the given byte buffer.
|
int |
downloadRangeToByteArray(long offset,
Long length,
byte[] buffer,
int bufferOffset,
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.
|
int |
downloadToByteArray(byte[] buffer,
int bufferOffet)
Downloads a range of bytes from the blob to the given byte buffer.
|
int |
downloadToByteArray(byte[] buffer,
int bufferOffset,
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(String path)
Downloads a blob, storing the contents in a file.
|
void |
downloadToFile(String path,
AccessCondition accessCondition,
BlobRequestOptions options,
OperationContext opContext)
Downloads a blob, storing the contents in a file.
|
boolean |
exists()
Checks to see if the blob exists.
|
boolean |
exists(AccessCondition accessCondition,
BlobRequestOptions options,
OperationContext opContext)
Checks to see if the blob exists, using the specified request options and operation context.
|
String |
generateSharedAccessSignature(SharedAccessBlobPolicy policy,
SharedAccessBlobHeaders headers,
String groupPolicyIdentifier)
Returns a shared access signature for the blob using the specified group policy identifier and operation context.
|
String |
generateSharedAccessSignature(SharedAccessBlobPolicy policy,
String groupPolicyIdentifier)
Returns a shared access signature for the blob using the specified group policy identifier and operation context.
|
CloudBlobContainer |
getContainer()
Returns the blob's container.
|
CopyState |
getCopyState()
Returns the blob's copy state.
|
HashMap<String,String> |
getMetadata()
Returns the metadata for the blob.
|
String |
getName()
Returns the name of the blob.
|
CloudBlobDirectory |
getParent()
Returns the blob item's parent.
|
protected static String |
getParentNameFromURI(StorageUri resourceAddress,
String delimiter,
CloudBlobContainer container)
Retrieves the parent name for a blob URI.
|
BlobProperties |
getProperties()
Returns the blob's properties.
|
StorageUri |
getQualifiedStorageUri()
Returns the snapshot or shared access signature qualified URI for this blob.
|
URI |
getQualifiedUri()
Returns the snapshot or shared access signature qualified URI for this blob.
|
CloudBlobClient |
getServiceClient()
Returns the Blob service client associated with the blob.
|
String |
getSnapshotID()
Gets the Blob Snapshot ID.
|
StorageUri |
getStorageUri()
Returns the list of URIs for all locations.
|
int |
getStreamMinimumReadSizeInBytes()
Returns the minimum read size when using a
BlobInputStream. |
int |
getStreamWriteSizeInBytes()
Gets the number of bytes to buffer when writing to a
BlobOutputStream (block and page blobs). |
protected StorageUri |
getTransformedAddress(OperationContext opContext)
Returns the transformed URI for the resource if the given credentials require transformation.
|
URI |
getUri()
Returns the URI for this blob.
|
boolean |
isSnapshot()
Indicates whether this blob is a snapshot.
|
BlobInputStream |
openInputStream()
Opens a blob input stream to download the blob.
|
BlobInputStream |
openInputStream(AccessCondition accessCondition,
BlobRequestOptions options,
OperationContext opContext)
Opens a blob input stream to download the blob using the specified request options and operation context.
|
protected void |
parseURIQueryStringAndVerify(StorageUri completeUri,
CloudBlobClient existingClient,
boolean usePathStyleUris)
Parse Uri for SAS (Shared access signature) information.
|
void |
releaseLease(AccessCondition accessCondition)
Releases the lease on the blob.
|
void |
releaseLease(AccessCondition accessCondition,
BlobRequestOptions options,
OperationContext opContext)
Releases the lease on the blob using the specified request options and operation context.
|
void |
renewLease(AccessCondition accessCondition)
Renews an existing lease.
|
void |
renewLease(AccessCondition accessCondition,
BlobRequestOptions options,
OperationContext opContext)
Renews an existing lease using the specified request options and operation context.
|
protected void |
setContainer(CloudBlobContainer container)
Sets the container for the blob.
|
void |
setMetadata(HashMap<String,String> metadata)
Sets the metadata for the blob.
|
protected void |
setProperties(BlobProperties properties)
Sets the properties for the blob.
|
protected void |
setSnapshotID(String snapshotID)
Sets the blob snapshot ID.
|
protected void |
setStorageUri(StorageUri storageUri)
Sets the list of URIs for all locations.
|
void |
setStreamMinimumReadSizeInBytes(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). |
String |
startCopyFromBlob(CloudBlob sourceBlob)
Requests the service to start copying a blob's contents, properties, and metadata to a new blob.
|
String |
startCopyFromBlob(CloudBlob sourceBlob,
AccessCondition sourceAccessCondition,
AccessCondition destinationAccessCondition,
BlobRequestOptions options,
OperationContext opContext)
Requests the service to start copying a blob's contents, properties, and metadata to a new blob, using the
specified access conditions, lease ID, request options, and operation context.
|
String |
startCopyFromBlob(URI source)
Requests the service to start copying a blob's contents, properties, and metadata to a new blob.
|
String |
startCopyFromBlob(URI source,
AccessCondition sourceAccessCondition,
AccessCondition destinationAccessCondition,
BlobRequestOptions options,
OperationContext opContext)
Requests the service to start copying a blob's contents, properties, and metadata to a new blob, using the
specified access conditions, lease ID, request options, and operation context.
|
protected void |
updateEtagAndLastModifiedFromResponse(HttpURLConnection request) |
protected void |
updateLengthFromResponse(HttpURLConnection request) |
abstract void |
upload(InputStream sourceStream,
long length)
Uploads the source stream data to the blob.
|
abstract void |
upload(InputStream sourceStream,
long length,
AccessCondition accessCondition,
BlobRequestOptions options,
OperationContext opContext)
Uploads the source stream data to the blob using the specified lease ID, request options, and operation context.
|
void |
uploadFromByteArray(byte[] buffer,
int offset,
int length)
Uploads a blob from data in a byte array.
|
void |
uploadFromByteArray(byte[] buffer,
int offset,
int length,
AccessCondition accessCondition,
BlobRequestOptions options,
OperationContext opContext)
Uploads a blob from data in a byte array.
|
void |
uploadFromFile(String path)
Uploads a blob from a file.
|
void |
uploadFromFile(String path,
AccessCondition accessCondition,
BlobRequestOptions options,
OperationContext opContext)
Uploads a blob from a file.
|
void |
uploadMetadata()
Uploads the blob's metadata to the storage service.
|
void |
uploadMetadata(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.
|
void |
uploadProperties()
Updates the blob's properties to the storage service.
|
void |
uploadProperties(AccessCondition accessCondition,
BlobRequestOptions options,
OperationContext opContext)
Updates the blob's properties using the specified lease ID, request options, and operation context.
|
protected CloudBlobDirectory parent
protected int streamWriteSizeInBytes
BlobOutputStream (block and page blobs).protected int streamMinimumReadSizeInBytes
BlobInputStream.protected CloudBlobClient blobServiceClient
protected CloudBlob(BlobType type)
CloudBlob class.type - A BlobType value which represents the type of the blob.protected CloudBlob(BlobType type, StorageUri uri, CloudBlobClient client) throws StorageException
CloudBlob class using the specified URI and cloud blob client.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.client - A CloudBlobClient object that specifies the endpoint for the Blob service.StorageException - If a storage service error occurred.protected CloudBlob(BlobType type, StorageUri uri, CloudBlobClient client, CloudBlobContainer container) throws StorageException
CloudBlob class using the specified URI, cloud blob client, and cloud
blob container.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.client - A CloudBlobClient object that specifies the endpoint for the Blob service.container - A CloudBlobContainer object that represents the container to use for the blob.StorageException - If a storage service error occurred.protected CloudBlob(BlobType type, StorageUri uri, String snapshotID, CloudBlobClient client) throws StorageException
CloudBlob class using the specified URI, snapshot ID, and cloud blob
client.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.client - A CloudBlobContainer object that represents the container to use for the blob.StorageException - If a storage service error occurred.protected CloudBlob(CloudBlob otherBlob)
CloudBlob class by copying values from another blob.otherBlob - A CloudBlob object that represents the blob to copy.@DoesServiceRequest public final void abortCopy(String copyId) throws StorageException
copyId - A String object that identifying the copy operation.StorageException - If a storage service error occurred.@DoesServiceRequest public final void abortCopy(String copyId, AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext) throws StorageException
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.StorageException - If a storage service error occurred.@DoesServiceRequest public final String acquireLease(Integer leaseTimeInSeconds, String proposedLeaseId) throws StorageException
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.String that represents the lease ID.StorageException - If a storage service error occurred.@DoesServiceRequest public final String acquireLease(Integer leaseTimeInSeconds, String proposedLeaseId, AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext) throws StorageException
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.String that represents the lease ID.StorageException - If a storage service error occurred.protected final void assertCorrectBlobType()
throws StorageException
StorageException - If an incorrect blob type is used.protected void assertNoWriteOperationForSnapshot()
@DoesServiceRequest public final long breakLease(Integer breakPeriodInSeconds) throws StorageException
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.long which specifies the time, in seconds, remaining in the lease period.StorageException - If a storage service error occurred.@DoesServiceRequest public final long breakLease(Integer breakPeriodInSeconds, AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext) throws StorageException
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.long which represents the time, in seconds, remaining in the lease period.StorageException - If a storage service error occurred.@DoesServiceRequest public final String changeLease(String proposedLeaseId, AccessCondition accessCondition) throws StorageException
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.String that represents the new lease ID.StorageException - If a storage service error occurred.@DoesServiceRequest public final String changeLease(String proposedLeaseId, AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext) throws StorageException
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.String that represents the new lease ID.StorageException - If a storage service error occurred.@DoesServiceRequest public final String startCopyFromBlob(CloudBlob sourceBlob) throws StorageException, URISyntaxException
sourceBlob - A CloudBlob object that represents the source blob to copy.String which represents the copy ID associated with the copy operation.StorageException - If a storage service error occurred.URISyntaxException@DoesServiceRequest public final String startCopyFromBlob(CloudBlob sourceBlob, AccessCondition sourceAccessCondition, AccessCondition destinationAccessCondition, BlobRequestOptions options, OperationContext opContext) throws StorageException, URISyntaxException
sourceBlob - A CloudBlob object that represents the source blob to copy.sourceAccessCondition - An AccessCondition object that represents the access conditions for the source blob.destinationAccessCondition - An AccessCondition object that represents the access conditions for the destination 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.String which represents the copy ID associated with the copy operation.StorageException - If a storage service error occurred.URISyntaxException@DoesServiceRequest public final String startCopyFromBlob(URI source) throws StorageException
source - A java.net.URI The URI of a source blob.String which represents the copy ID associated with the copy operation.StorageException - If a storage service error occurred.@DoesServiceRequest public final String startCopyFromBlob(URI source, AccessCondition sourceAccessCondition, AccessCondition destinationAccessCondition, BlobRequestOptions options, OperationContext opContext) throws StorageException
source - A java.net.URI The URI of a source blob.sourceAccessCondition - An AccessCondition object that represents the access conditions for the source blob.destinationAccessCondition - An AccessCondition object that represents the access conditions for the destination 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.String which represents the copy ID associated with the copy operation.StorageException - If a storage service error occurred.@DoesServiceRequest public final CloudBlob createSnapshot() throws StorageException
CloudBlob object that represents the snapshot of the blob.StorageException - If a storage service error occurred.@DoesServiceRequest public final CloudBlob createSnapshot(AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext) throws StorageException
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.CloudBlob object that represents the snapshot of the blob.StorageException - If a storage service error occurred.@DoesServiceRequest public final CloudBlob createSnapshot(HashMap<String,String> metadata, AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext) throws StorageException
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.CloudBlob object that represents the snapshot of the blob.StorageException - If a storage service error occurred.@DoesServiceRequest public final void delete() throws StorageException
StorageException - If a storage service error occurred.@DoesServiceRequest public final void delete(DeleteSnapshotsOption deleteSnapshotsOption, AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext) throws StorageException
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 deleteSnapshotsOption parameter to specify how the snapshots should be handled when the blob
is deleted.
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.StorageException - If a storage service error occurred.@DoesServiceRequest public final boolean deleteIfExists() throws StorageException
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 deleteSnapshotsOption parameter to specify how the snapshots should be handled when the blob
is deleted.
true if the blob was deleted; otherwise, false.StorageException - If a storage service error occurred.@DoesServiceRequest public final boolean deleteIfExists(DeleteSnapshotsOption deleteSnapshotsOption, AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext) throws StorageException
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 deleteSnapshotsOption parameter to specify how the snapshots should be handled when the blob
is deleted.
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.true if the blob existed and was deleted; otherwise, falseStorageException - If a storage service error occurred.@DoesServiceRequest public final void download(OutputStream outStream) throws StorageException
outStream - An OutputStream object that represents the target stream.StorageException - If a storage service error occurred.@DoesServiceRequest public final void download(OutputStream outStream, AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext) throws StorageException
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.StorageException - If a storage service error occurred.@DoesServiceRequest public final void downloadRange(long offset, Long length, OutputStream outStream) throws StorageException
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.StorageException - If a storage service error occurred.@DoesServiceRequest public final void downloadRange(long offset, Long length, OutputStream outStream, AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext) throws StorageException
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.StorageException - If a storage service error occurred.@DoesServiceRequest public final void downloadAttributes() throws StorageException
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.
StorageException - If a storage service error occurred.@DoesServiceRequest public final void downloadAttributes(AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext) throws StorageException
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.
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.StorageException - If a storage service error occurred.@DoesServiceRequest protected final int downloadRangeInternal(long blobOffset, Long length, byte[] buffer, int bufferOffset, AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext) throws StorageException
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.StorageException - an exception representing any error which occurred during the operation.@DoesServiceRequest public final int downloadRangeToByteArray(long offset, Long length, byte[] buffer, int bufferOffet) throws StorageException
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.bufferOffet - An int which represents the byte offset to use as the starting point for the target.StorageException@DoesServiceRequest public final int downloadRangeToByteArray(long offset, Long length, byte[] buffer, int bufferOffset, AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext) throws StorageException
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.StorageException - If a storage service error occurred.@DoesServiceRequest public final int downloadToByteArray(byte[] buffer, int bufferOffet) throws StorageException
buffer - A byte array which represents the buffer to which the blob bytes are downloaded.bufferOffet - An int which represents the byte offset to use as the starting point for the target.StorageException - If a storage service error occurred.@DoesServiceRequest public final int downloadToByteArray(byte[] buffer, int bufferOffset, AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext) throws StorageException
buffer - A byte array which represents the buffer to which the blob bytes are downloaded.bufferOffet - 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.StorageException - If a storage service error occurred.public void uploadFromByteArray(byte[] buffer,
int offset,
int length)
throws StorageException,
IOException
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.StorageException - If a storage service error occurred.IOExceptionpublic void uploadFromByteArray(byte[] buffer,
int offset,
int length,
AccessCondition accessCondition,
BlobRequestOptions options,
OperationContext opContext)
throws StorageException,
IOException
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.StorageException - If a storage service error occurred.IOExceptionpublic void uploadFromFile(String path) throws StorageException, IOException
path - A String which represents the path to the file to be uploaded.StorageException - If a storage service error occurred.IOExceptionpublic void uploadFromFile(String path, AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext) throws StorageException, IOException
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.StorageException - If a storage service error occurred.IOExceptionpublic void downloadToFile(String path) throws StorageException, IOException
path - A String which represents the path to the file that will be created with the contents of
the blob.StorageException - If a storage service error occurred.IOExceptionpublic void downloadToFile(String path, AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext) throws StorageException, IOException
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.StorageException - If a storage service error occurred.IOException@DoesServiceRequest public final boolean exists() throws StorageException
true if the blob exists, otherwise false.StorageException - If a storage service error occurred.@DoesServiceRequest public final boolean exists(AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext) throws StorageException
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.true if the blob exists, other wise false.StorageException - If a storage service error occurred.public String generateSharedAccessSignature(SharedAccessBlobPolicy policy, String groupPolicyIdentifier) throws InvalidKeyException, StorageException
policy - A SharedAccessPolicy object that represents the access policy for the shared access
signature.groupPolicyIdentifier - A String that represents the container-level access policy.String that represents the shared access signature.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.public String generateSharedAccessSignature(SharedAccessBlobPolicy policy, SharedAccessBlobHeaders headers, String groupPolicyIdentifier) throws InvalidKeyException, StorageException
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.String that represents the shared access signature.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.public final CloudBlobContainer getContainer() throws StorageException, URISyntaxException
getContainer in interface ListBlobItemCloudBlobContainer object that represents the container of the blob.StorageException - If a storage service error occurred.URISyntaxException - If the resource URI is invalid.public final HashMap<String,String> getMetadata()
java.util.HashMap object that represents the metadata for the blob.public final String getName() throws URISyntaxException
String that represents the name of the blob.URISyntaxException - If the resource URI is invalid.public final CloudBlobDirectory getParent() throws URISyntaxException, StorageException
getParent in interface ListBlobItemCloudBlobDirectory object that represents the parent directory for the blob.StorageException - If a storage service error occurred.URISyntaxException - If the resource URI is invalid.public final BlobProperties getProperties()
BlobProperties object that represents the properties of the blob.public CopyState getCopyState()
CopyState object that represents the copy state of the blob.public final StorageUri getQualifiedStorageUri() throws URISyntaxException, StorageException
StorageUri object that represents the snapshot or shared access signature.StorageException - If a storage service error occurred.URISyntaxException - If the resource URI is invalid.public final URI getQualifiedUri() throws URISyntaxException, StorageException
java.net.URI object that represents the snapshot or shared access signature.StorageException - If a storage service error occurred.URISyntaxException - If the resource URI is invalid.public final CloudBlobClient getServiceClient()
CloudBlobClient object that represents the client.public final String getSnapshotID()
String which represents the Blob Snapshot ID.public final StorageUri getStorageUri()
getStorageUri in interface ListBlobItemStorageUri that represents the list of URIs for all locations..public final int getStreamWriteSizeInBytes()
BlobOutputStream (block and page blobs).int which represents the number of bytes to buffer or the size of a block, in bytes.public final int getStreamMinimumReadSizeInBytes()
BlobInputStream.int which represents the minimum read size, in bytes, when using a BlobInputStream
object.protected final StorageUri getTransformedAddress(OperationContext opContext) throws URISyntaxException, StorageException
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.StorageUri object that represents the transformed URI.IllegalArgumentException - If the URI is not absolute.StorageException - If a storage service error occurred.URISyntaxException - If the resource URI is invalid.public final URI getUri()
getUri in interface ListBlobItemjava.net.URI object that represents the URI for the blob.public final boolean isSnapshot()
true if the blob is a snapshot, otherwise false.DeleteSnapshotsOption@DoesServiceRequest public final BlobInputStream openInputStream() throws StorageException
Use CloudBlobClient#setStreamMinimumReadSizeInBytes to configure the read size.
InputStream object that represents the stream to use for reading from the blob.StorageException - If a storage service error occurred.@DoesServiceRequest public final BlobInputStream openInputStream(AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext) throws StorageException
Use CloudBlobClient#setStreamMinimumReadSizeInBytes to configure the read size.
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.InputStream object that represents the stream to use for reading from the blob.StorageException - If a storage service error occurred.protected void parseURIQueryStringAndVerify(StorageUri completeUri, CloudBlobClient existingClient, boolean usePathStyleUris) throws StorageException
completeUri - A StorageUri object which represents the complete Uri.existingClient - A CloudBlobClient object which represents the client to use.usePathStyleUris - true if path-style URIs are used; otherwise, false.StorageException - If a storage service error occurred.@DoesServiceRequest public final void releaseLease(AccessCondition accessCondition) throws StorageException
accessCondition - An AccessCondition object that represents the access conditions for the blob. The LeaseID is
required to be set on the AccessCondition.StorageException - If a storage service error occurred.@DoesServiceRequest public final void releaseLease(AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext) throws StorageException
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.StorageException - If a storage service error occurred.@DoesServiceRequest public final void renewLease(AccessCondition accessCondition) throws StorageException
accessCondition - An AccessCondition object that represents the access conditions for the blob. The LeaseID is
required to be set on the AccessCondition.StorageException - If a storage service error occurred.@DoesServiceRequest public final void renewLease(AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext) throws StorageException
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.StorageException - If a storage service error occurred.protected final void setContainer(CloudBlobContainer container)
container - A CloudBlobContainer object that represents the container being assigned to the blob.public final void setMetadata(HashMap<String,String> metadata)
metadata - A java.util.HashMap object that contains the metadata being assigned to the blob.protected final void setProperties(BlobProperties properties)
properties - A BlobProperties object that represents the properties being assigned to the blob.protected final void setSnapshotID(String snapshotID)
snapshotID - A String that represents the snapshot ID being assigned to the blob.protected void setStorageUri(StorageUri storageUri)
storageUri - A StorageUri that represents the list of URIs for all locations.public abstract void setStreamWriteSizeInBytes(int streamWriteSizeInBytes)
BlobOutputStream (block and page blobs).streamWriteSizeInBytes - An int that represents the number of bytes to buffer or the size of a block, in bytes.public void setStreamMinimumReadSizeInBytes(int minimumReadSize)
BlobInputStream.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.IllegalArgumentException - If minimumReadSize is less than 16 KB.protected void updateEtagAndLastModifiedFromResponse(HttpURLConnection request)
protected void updateLengthFromResponse(HttpURLConnection request)
@DoesServiceRequest public abstract void upload(InputStream sourceStream, long length) throws StorageException, IOException
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.IOException - If an I/O exception occurred.StorageException - If a storage service error occurred.@DoesServiceRequest public abstract void upload(InputStream sourceStream, long length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext) throws StorageException, IOException
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.IOException - If an I/O exception occurred.StorageException - If a storage service error occurred.@DoesServiceRequest public final void uploadMetadata() throws StorageException
Use downloadAttributes() to retrieve the latest values for the blob's properties and metadata
from the Microsoft Azure storage service.
StorageException - If a storage service error occurred.@DoesServiceRequest public final void uploadMetadata(AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext) throws StorageException
Use downloadAttributes() to retrieve the latest values for the blob's properties and metadata
from the Microsoft Azure storage service.
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.StorageException - If a storage service error occurred.@DoesServiceRequest public final void uploadProperties() throws StorageException
Use downloadAttributes() to retrieve the latest values for the blob's properties and metadata
from the Microsoft Azure storage service.
StorageException - If a storage service error occurred.@DoesServiceRequest public final void uploadProperties(AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext) throws StorageException
Use downloadAttributes() to retrieve the latest values for the blob's properties and metadata
from the Microsoft Azure storage service.
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.StorageException - If a storage service error occurred.protected static String getParentNameFromURI(StorageUri resourceAddress, String delimiter, CloudBlobContainer container) throws URISyntaxException
resourceAddress - A StorageUri object which represents the resource URI.delimiter - A String which specifies the directory delimiter to use.usePathStyleUris - A CloudBlobContainer object which represents the blob container.String which represents the parent address for a blob URI.URISyntaxException/**
* Copyright Microsoft Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/