use of com.microsoft.azure.storage.blob.CloudBlockBlob in project camel by apache.
the class BlobServiceProducer method getBlobBlockList.
private void getBlobBlockList(Exchange exchange) throws Exception {
CloudBlockBlob client = BlobServiceUtil.createBlockBlobClient(getConfiguration());
BlobServiceRequestOptions opts = BlobServiceUtil.getRequestOptions(exchange);
LOG.trace("Getting the blob block list [{}] from exchange [{}]...", getConfiguration().getBlobName(), exchange);
BlockListingFilter filter = exchange.getIn().getBody(BlockListingFilter.class);
if (filter == null) {
filter = BlockListingFilter.COMMITTED;
}
List<BlockEntry> blockEntries = client.downloadBlockList(filter, opts.getAccessCond(), opts.getRequestOpts(), opts.getOpContext());
ExchangeUtil.getMessageForResponse(exchange).setBody(blockEntries);
}
use of com.microsoft.azure.storage.blob.CloudBlockBlob in project camel by apache.
the class BlobServiceProducer method uploadBlobBlocks.
private void uploadBlobBlocks(Exchange exchange) throws Exception {
Object object = exchange.getIn().getMandatoryBody();
List<BlobBlock> blobBlocks = null;
if (object instanceof List) {
blobBlocks = (List<BlobBlock>) blobBlocks;
} else if (object instanceof BlobBlock) {
blobBlocks = Collections.singletonList((BlobBlock) object);
}
if (blobBlocks == null || blobBlocks.isEmpty()) {
throw new IllegalArgumentException("Illegal storageBlocks payload");
}
CloudBlockBlob client = BlobServiceUtil.createBlockBlobClient(getConfiguration());
configureCloudBlobForWrite(client);
BlobServiceRequestOptions opts = BlobServiceUtil.getRequestOptions(exchange);
LOG.trace("Putting a blob [{}] from blocks from exchange [{}]...", getConfiguration().getBlobName(), exchange);
List<BlockEntry> blockEntries = new LinkedList<BlockEntry>();
for (BlobBlock blobBlock : blobBlocks) {
blockEntries.add(blobBlock.getBlockEntry());
client.uploadBlock(blobBlock.getBlockEntry().getId(), blobBlock.getBlockStream(), -1, opts.getAccessCond(), opts.getRequestOpts(), opts.getOpContext());
}
Boolean commitBlockListLater = exchange.getIn().getHeader(BlobServiceConstants.COMMIT_BLOCK_LIST_LATER, Boolean.class);
if (Boolean.TRUE != commitBlockListLater) {
client.commitBlockList(blockEntries, opts.getAccessCond(), opts.getRequestOpts(), opts.getOpContext());
}
}
use of com.microsoft.azure.storage.blob.CloudBlockBlob in project camel by apache.
the class BlobServiceUtil method getBlockBlob.
private static void getBlockBlob(Exchange exchange, BlobServiceConfiguration cfg) throws Exception {
CloudBlockBlob client = createBlockBlobClient(cfg);
doGetBlob(client, exchange, cfg);
}
use of com.microsoft.azure.storage.blob.CloudBlockBlob in project camel by apache.
the class BlobServiceComponentConfigurationTest method testClientWithoutCredentials.
@Test
public void testClientWithoutCredentials() throws Exception {
CloudBlockBlob client = new CloudBlockBlob(URI.create("https://camelazure.blob.core.windows.net/container/blob"));
doTestClientWithoutCredentials(client);
}
use of com.microsoft.azure.storage.blob.CloudBlockBlob in project camel by apache.
the class BlobServiceComponentConfigurationTest method testClientWithoutAnonymousCredentials.
@Test
public void testClientWithoutAnonymousCredentials() throws Exception {
CloudBlockBlob client = new CloudBlockBlob(URI.create("https://camelazure.blob.core.windows.net/container/blob"), StorageCredentialsAnonymous.ANONYMOUS);
doTestClientWithoutCredentials(client);
}
Aggregations