use of com.microsoft.azure.storage.blob.CloudBlockBlob in project camel by apache.
the class BlobServiceProducer method updateBlockBlob.
private void updateBlockBlob(Exchange exchange) throws Exception {
CloudBlockBlob client = BlobServiceUtil.createBlockBlobClient(getConfiguration());
configureCloudBlobForWrite(client);
BlobServiceRequestOptions opts = BlobServiceUtil.getRequestOptions(exchange);
InputStream inputStream = getInputStreamFromExchange(exchange);
LOG.trace("Putting a block blob [{}] from exchange [{}]...", getConfiguration().getBlobName(), exchange);
try {
client.upload(inputStream, -1, opts.getAccessCond(), opts.getRequestOpts(), opts.getOpContext());
} finally {
closeInputStreamIfNeeded(inputStream);
}
}
use of com.microsoft.azure.storage.blob.CloudBlockBlob in project camel by apache.
the class BlobServiceProducer method commitBlobBlockList.
private void commitBlobBlockList(Exchange exchange) throws Exception {
Object object = exchange.getIn().getMandatoryBody();
List<BlockEntry> blockEntries = null;
if (object instanceof List) {
blockEntries = (List<BlockEntry>) blockEntries;
} else if (object instanceof BlockEntry) {
blockEntries = Collections.singletonList((BlockEntry) object);
}
if (blockEntries == null || blockEntries.isEmpty()) {
throw new IllegalArgumentException("Illegal commit block list payload");
}
CloudBlockBlob client = BlobServiceUtil.createBlockBlobClient(getConfiguration());
BlobServiceRequestOptions opts = BlobServiceUtil.getRequestOptions(exchange);
LOG.trace("Putting a blob [{}] block list from exchange [{}]...", getConfiguration().getBlobName(), exchange);
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 createBlockBlobClient.
public static CloudBlockBlob createBlockBlobClient(BlobServiceConfiguration cfg) throws Exception {
CloudBlockBlob client = (CloudBlockBlob) getConfiguredClient(cfg);
if (client == null) {
URI uri = prepareStorageBlobUri(cfg);
StorageCredentials creds = getAccountCredentials(cfg);
client = new CloudBlockBlob(uri, creds);
}
return client;
}
use of com.microsoft.azure.storage.blob.CloudBlockBlob in project camel by apache.
the class BlobServiceComponentConfigurationTest method testClientWithoutCredentialsPublicRead.
@Test
public void testClientWithoutCredentialsPublicRead() throws Exception {
CloudBlockBlob client = new CloudBlockBlob(URI.create("https://camelazure.blob.core.windows.net/container/blob"));
JndiRegistry registry = (JndiRegistry) ((PropertyPlaceholderDelegateRegistry) context.getRegistry()).getRegistry();
registry.bind("azureBlobClient", client);
BlobServiceComponent component = new BlobServiceComponent(context);
BlobServiceEndpoint endpoint = (BlobServiceEndpoint) component.createEndpoint("azure-blob://camelazure/container/blob?azureBlobClient=#azureBlobClient&publicForRead=true");
assertTrue(endpoint.getConfiguration().isPublicForRead());
}
use of com.microsoft.azure.storage.blob.CloudBlockBlob in project camel by apache.
the class BlobServiceComponentConfigurationTest method testCreateEndpointWithMinConfigForClientOnly.
@Test
public void testCreateEndpointWithMinConfigForClientOnly() throws Exception {
CloudBlockBlob client = new CloudBlockBlob(URI.create("https://camelazure.blob.core.windows.net/container/blob"), newAccountKeyCredentials());
JndiRegistry registry = (JndiRegistry) ((PropertyPlaceholderDelegateRegistry) context.getRegistry()).getRegistry();
registry.bind("azureBlobClient", client);
BlobServiceComponent component = new BlobServiceComponent(context);
BlobServiceEndpoint endpoint = (BlobServiceEndpoint) component.createEndpoint("azure-blob://camelazure/container/blob?azureBlobClient=#azureBlobClient");
doTestCreateEndpointWithMinConfig(endpoint, true);
}
Aggregations