EncryptedBlobClient Class
- java.
lang. Object - com.
azure. storage. blob. specialized. BlobClientBase - com.
azure. storage. blob. BlobClient - com.
azure. storage. blob. specialized. cryptography. EncryptedBlobClient
- com.
- com.
- com.
public class EncryptedBlobClient
extends BlobClient
This class provides a client side encryption client that contains generic blob operations for Azure Storage Blobs. Operations allowed by the client are uploading, downloading and copying a blob, retrieving and setting metadata, retrieving and setting HTTP headers, and deleting and un-deleting a blob. The upload and download operation allow for encryption and decryption of the data client side. Note: setting metadata in particular is unsafe and should only be done so with caution.
Please refer to the Azure Docs For Client-Side Encryption for more information.
This client is instantiated through EncryptedBlobClientBuilder
For operations on a specific blob type (i.e. append, block, or page) use getAppendBlobClient(), getBlockBlobClient(), or getPageBlobClient() to construct a client that allows blob specific operations. Note, these types do not support client-side encryption, though decryption is possible in case the associated block/page/append blob contains encrypted data.
Please refer to the Azure Docs for more information.
Method Summary
Methods inherited from BlobClient
Methods inherited from BlobClientBase
Methods inherited from java.lang.Object
Method Details
download
@Deprecated
public void download(OutputStream stream)
Overrides:
EncryptedBlobClient.download(OutputStream stream)Parameters:
downloadContent
public BinaryData downloadContent()
Overrides:
EncryptedBlobClient.downloadContent()downloadContentWithResponse
public BlobDownloadContentResponse downloadContentWithResponse(DownloadRetryOptions options, BlobRequestConditions requestConditions, Duration timeout, Context context)
Overrides:
EncryptedBlobClient.downloadContentWithResponse(DownloadRetryOptions options, BlobRequestConditions requestConditions, Duration timeout, Context context)Parameters:
downloadStream
public void downloadStream(OutputStream stream)
Overrides:
EncryptedBlobClient.downloadStream(OutputStream stream)Parameters:
downloadStreamWithResponse
public BlobDownloadResponse downloadStreamWithResponse(OutputStream stream, BlobRange range, DownloadRetryOptions options, BlobRequestConditions requestConditions, boolean getRangeContentMd5, Duration timeout, Context context)
Overrides:
EncryptedBlobClient.downloadStreamWithResponse(OutputStream stream, BlobRange range, DownloadRetryOptions options, BlobRequestConditions requestConditions, boolean getRangeContentMd5, Duration timeout, Context context)Parameters:
downloadToFile
public BlobProperties downloadToFile(String filePath)
Overrides:
EncryptedBlobClient.downloadToFile(String filePath)Parameters:
downloadToFile
public BlobProperties downloadToFile(String filePath, boolean overwrite)
Overrides:
EncryptedBlobClient.downloadToFile(String filePath, boolean overwrite)Parameters:
downloadToFileWithResponse
public Response
Overrides:
EncryptedBlobClient.downloadToFileWithResponse(BlobDownloadToFileOptions options, Duration timeout, Context context)Parameters:
downloadToFileWithResponse
public Response
Overrides:
EncryptedBlobClient.downloadToFileWithResponse(String filePath, BlobRange range, ParallelTransferOptions parallelTransferOptions, DownloadRetryOptions downloadRetryOptions, BlobRequestConditions requestConditions, boolean rangeGetContentMd5, Duration timeout, Context context)Parameters:
downloadToFileWithResponse
public Response
Overrides:
EncryptedBlobClient.downloadToFileWithResponse(String filePath, BlobRange range, ParallelTransferOptions parallelTransferOptions, DownloadRetryOptions downloadRetryOptions, BlobRequestConditions requestConditions, boolean rangeGetContentMd5, Set<OpenOption> openOptions, Duration timeout, Context context)Parameters:
downloadWithResponse
@Deprecated
public BlobDownloadResponse downloadWithResponse(OutputStream stream, BlobRange range, DownloadRetryOptions options, BlobRequestConditions requestConditions, boolean getRangeContentMd5, Duration timeout, Context context)
Overrides:
EncryptedBlobClient.downloadWithResponse(OutputStream stream, BlobRange range, DownloadRetryOptions options, BlobRequestConditions requestConditions, boolean getRangeContentMd5, Duration timeout, Context context)Parameters:
getAppendBlobClient
public AppendBlobClient getAppendBlobClient()
Unsupported.
Overrides:
EncryptedBlobClient.getAppendBlobClient()getBlobOutputStream
public BlobOutputStream getBlobOutputStream()
Creates and opens an output stream to write data to the block blob.
Note: We recommend you call write with reasonably sized buffers, you can do so by wrapping the BlobOutputStream obtained below with a BufferedOutputStream.
Returns:
getBlobOutputStream
public BlobOutputStream getBlobOutputStream(boolean overwrite)
Creates and opens an output stream to write data to the block blob.
Note: We recommend you call write with reasonably sized buffers, you can do so by wrapping the BlobOutputStream obtained below with a BufferedOutputStream.
Parameters:
Returns:
getBlobOutputStream
public BlobOutputStream getBlobOutputStream(ParallelTransferOptions parallelTransferOptions, BlobHttpHeaders headers, Map
Creates and opens an output stream to write data to the block blob. If the blob already exists on the service, it will be overwritten.
To avoid overwriting, pass "*" to BlobRequestConditions#setIfNoneMatch(String).
Note: We recommend you call write with reasonably sized buffers, you can do so by wrapping the BlobOutputStream obtained below with a BufferedOutputStream.
Parameters:
Returns:
getBlobOutputStream
public BlobOutputStream getBlobOutputStream(BlockBlobOutputStreamOptions options)
Creates and opens an output stream to write data to the block blob. If the blob already exists on the service, it will be overwritten.
To avoid overwriting, pass "*" to BlobRequestConditions#setIfNoneMatch(String).
Note: We recommend you call write with reasonably sized buffers, you can do so by wrapping the BlobOutputStream obtained below with a BufferedOutputStream.
Parameters:
Returns:
getBlockBlobClient
public BlockBlobClient getBlockBlobClient()
Unsupported.
Overrides:
EncryptedBlobClient.getBlockBlobClient()getCustomerProvidedKeyClient
public EncryptedBlobClient getCustomerProvidedKeyClient(CustomerProvidedKey customerProvidedKey)
Creates a new EncryptedBlobClient with the specified customerProvidedKey
.
Overrides:
EncryptedBlobClient.getCustomerProvidedKeyClient(CustomerProvidedKey customerProvidedKey)Parameters:
null
to use no customer provided key.
Returns:
customerProvidedKey
.getEncryptionScopeClient
public EncryptedBlobClient getEncryptionScopeClient(String encryptionScope)
Creates a new EncryptedBlobClient with the specified encryptionScope
.
Overrides:
EncryptedBlobClient.getEncryptionScopeClient(String encryptionScope)Parameters:
null
to use no encryption scope.
Returns:
encryptionScope
.getPageBlobClient
public PageBlobClient getPageBlobClient()
Unsupported.
Overrides:
EncryptedBlobClient.getPageBlobClient()openInputStream
public BlobInputStream openInputStream()
Overrides:
EncryptedBlobClient.openInputStream()openInputStream
public BlobInputStream openInputStream(BlobRange range, BlobRequestConditions requestConditions)
Overrides:
EncryptedBlobClient.openInputStream(BlobRange range, BlobRequestConditions requestConditions)Parameters:
openInputStream
public BlobInputStream openInputStream(BlobInputStreamOptions options)
Overrides:
EncryptedBlobClient.openInputStream(BlobInputStreamOptions options)Parameters:
openInputStream
public BlobInputStream openInputStream(BlobInputStreamOptions options, Context context)
Overrides:
EncryptedBlobClient.openInputStream(BlobInputStreamOptions options, Context context)Parameters:
openQueryInputStream
public InputStream openQueryInputStream(String expression)
Unsupported. Cannot query data encrypted on client side.
Overrides:
EncryptedBlobClient.openQueryInputStream(String expression)Parameters:
openQueryInputStreamWithResponse
public Response
Unsupported. Cannot query data encrypted on client side.
Overrides:
EncryptedBlobClient.openQueryInputStreamWithResponse(BlobQueryOptions queryOptions)Parameters:
query
public void query(OutputStream stream, String expression)
Unsupported. Cannot query data encrypted on client side.
Overrides:
EncryptedBlobClient.query(OutputStream stream, String expression)Parameters:
queryWithResponse
public BlobQueryResponse queryWithResponse(BlobQueryOptions queryOptions, Duration timeout, Context context)
Unsupported. Cannot query data encrypted on client side.
Overrides:
EncryptedBlobClient.queryWithResponse(BlobQueryOptions queryOptions, Duration timeout, Context context)Parameters:
uploadFromFile
public void uploadFromFile(String filePath)
Creates a new block blob, or updates the content of an existing block blob.
Code Samples
try {
client.uploadFromFile(filePath);
System.out.println("Upload from file succeeded");
} catch (UncheckedIOException ex) {
System.err.printf("Failed to upload from file %s%n", ex.getMessage());
}
Overrides:
EncryptedBlobClient.uploadFromFile(String filePath)Parameters:
uploadFromFile
public void uploadFromFile(String filePath, boolean overwrite)
Creates a new block blob, or updates the content of an existing block blob.
Code Samples
try {
boolean overwrite = false; // Default value
client.uploadFromFile(filePath, overwrite);
System.out.println("Upload from file succeeded");
} catch (UncheckedIOException ex) {
System.err.printf("Failed to upload from file %s%n", ex.getMessage());
}
Overrides:
EncryptedBlobClient.uploadFromFile(String filePath, boolean overwrite)Parameters:
uploadFromFile
public void uploadFromFile(String filePath, ParallelTransferOptions parallelTransferOptions, BlobHttpHeaders headers, Map
Creates a new block blob, or updates the content of an existing block blob.
Code Samples
BlobHttpHeaders headers = new BlobHttpHeaders()
.setContentMd5("data".getBytes(StandardCharsets.UTF_8))
.setContentLanguage("en-US")
.setContentType("binary");
Map<String, String> metadata = new HashMap<>(Collections.singletonMap("metadata", "value"));
BlobRequestConditions requestConditions = new BlobRequestConditions()
.setLeaseId(leaseId)
.setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
long blockSize = 100 * 1024 * 1024; // 100 MB;
ParallelTransferOptions parallelTransferOptions = new ParallelTransferOptions().setBlockSizeLong(blockSize);
try {
client.uploadFromFile(filePath, parallelTransferOptions, headers, metadata, AccessTier.HOT,
requestConditions, timeout);
System.out.println("Upload from file succeeded");
} catch (UncheckedIOException ex) {
System.err.printf("Failed to upload from file %s%n", ex.getMessage());
}
Overrides:
EncryptedBlobClient.uploadFromFile(String filePath, ParallelTransferOptions parallelTransferOptions, BlobHttpHeaders headers, Map<String,String> metadata, AccessTier tier, BlobRequestConditions requestConditions, Duration timeout)Parameters:
Throws:
uploadFromFileWithResponse
public Response
Creates a new block blob, or updates the content of an existing block blob.
Code Samples
BlobHttpHeaders headers = new BlobHttpHeaders()
.setContentMd5("data".getBytes(StandardCharsets.UTF_8))
.setContentLanguage("en-US")
.setContentType("binary");
Map<String, String> metadata = new HashMap<>(Collections.singletonMap("metadata", "value"));
Map<String, String> tags = new HashMap<>(Collections.singletonMap("tag", "value"));
BlobRequestConditions requestConditions = new BlobRequestConditions()
.setLeaseId(leaseId)
.setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
long blockSize = 100 * 1024 * 1024; // 100 MB;
ParallelTransferOptions parallelTransferOptions = new ParallelTransferOptions().setBlockSizeLong(blockSize);
try {
client.uploadFromFileWithResponse(new BlobUploadFromFileOptions(filePath)
.setParallelTransferOptions(parallelTransferOptions).setHeaders(headers).setMetadata(metadata)
.setTags(tags).setTier(AccessTier.HOT).setRequestConditions(requestConditions), timeout,
Context.NONE);
System.out.println("Upload from file succeeded");
} catch (UncheckedIOException ex) {
System.err.printf("Failed to upload from file %s%n", ex.getMessage());
}
Overrides:
EncryptedBlobClient.uploadFromFileWithResponse(BlobUploadFromFileOptions options, Duration timeout, Context context)Parameters:
Returns:
Throws:
Applies to
Azure SDK for Java