use of com.microsoft.azure.storage.blob.CloudAppendBlob in project camel by apache.
the class BlobServiceProducer method updateAppendBlob.
private void updateAppendBlob(Exchange exchange) throws Exception {
CloudAppendBlob client = BlobServiceUtil.createAppendBlobClient(getConfiguration());
configureCloudBlobForWrite(client);
BlobServiceRequestOptions opts = BlobServiceUtil.getRequestOptions(exchange);
if (opts.getAccessCond() == null) {
// Default: do not reset the blob content if the blob already exists
opts.setAccessCond(AccessCondition.generateIfNotExistsCondition());
}
Boolean appendBlobCreated = exchange.getIn().getHeader(BlobServiceConstants.APPEND_BLOCK_CREATED, Boolean.class);
if (Boolean.TRUE != appendBlobCreated) {
doCreateAppendBlob(client, opts, exchange);
}
InputStream inputStream = getInputStreamFromExchange(exchange);
try {
client.appendBlock(inputStream, -1, opts.getAccessCond(), opts.getRequestOpts(), opts.getOpContext());
} finally {
closeInputStreamIfNeeded(inputStream);
}
}
use of com.microsoft.azure.storage.blob.CloudAppendBlob in project camel by apache.
the class BlobServiceUtil method getAppendBlob.
private static void getAppendBlob(Exchange exchange, BlobServiceConfiguration cfg) throws Exception {
CloudAppendBlob client = createAppendBlobClient(cfg);
doGetBlob(client, exchange, cfg);
}
use of com.microsoft.azure.storage.blob.CloudAppendBlob in project wildfly-camel by wildfly-extras.
the class AzureIntegrationTest method testAppendBlob.
@Test
public void testAppendBlob() throws Exception {
StorageCredentials creds = getStorageCredentials("camelblob", System.getenv(AZURE_STORAGE_BLOB));
Assume.assumeNotNull("Credentials not null", creds);
CamelContext camelctx = createCamelContext(creds);
camelctx.addRoutes(new RouteBuilder() {
public void configure() throws Exception {
from("direct:start").to("azure-blob://camelblob/container1/blobAppend?credentials=#creds&operation=updateAppendBlob");
from("azure-blob://camelblob/container1/blobAppend?credentials=#creds&blobType=appendblob").to("mock:read");
from("direct:list").to("azure-blob://camelblob/container1?credentials=#creds&operation=listBlobs");
}
});
camelctx.start();
try {
MockEndpoint mockRead = camelctx.getEndpoint("mock:read", MockEndpoint.class);
mockRead.expectedBodiesReceived("Append Blob");
mockRead.expectedMessageCount(1);
ProducerTemplate producer = camelctx.createProducerTemplate();
Iterator<?> it = producer.requestBody("direct:list", null, Iterable.class).iterator();
Assert.assertFalse("No Blob exists", it.hasNext());
// append to blob
producer.sendBody("direct:start", "Append Blob");
mockRead.assertIsSatisfied();
it = producer.requestBody("direct:list", null, Iterable.class).iterator();
Assert.assertTrue("Blob exists", it.hasNext());
CloudBlob blob = (CloudAppendBlob) it.next();
blob.delete();
it = producer.requestBody("direct:list", null, Iterable.class).iterator();
Assert.assertFalse("No Blob exists", it.hasNext());
} finally {
camelctx.stop();
}
}
use of com.microsoft.azure.storage.blob.CloudAppendBlob in project jackrabbit-oak by apache.
the class AzureJournalFile method getJournalBlobs.
private List<CloudAppendBlob> getJournalBlobs() throws IOException {
try {
List<CloudAppendBlob> result = new ArrayList<>();
for (ListBlobItem b : directory.listBlobs(journalNamePrefix)) {
if (b instanceof CloudAppendBlob) {
result.add((CloudAppendBlob) b);
} else {
log.warn("Invalid blob type: {} {}", b.getUri(), b.getClass());
}
}
result.sort(Comparator.<CloudAppendBlob, String>comparing(AzureUtilities::getName).reversed());
return result;
} catch (URISyntaxException | StorageException e) {
throw new IOException(e);
}
}
use of com.microsoft.azure.storage.blob.CloudAppendBlob in project camel by apache.
the class BlobServiceProducer method createAppendBlob.
private void createAppendBlob(Exchange exchange) throws Exception {
CloudAppendBlob client = BlobServiceUtil.createAppendBlobClient(getConfiguration());
BlobServiceRequestOptions opts = BlobServiceUtil.getRequestOptions(exchange);
if (opts.getAccessCond() == null) {
// Default: do not reset the blob content if the blob already exists
opts.setAccessCond(AccessCondition.generateIfNotExistsCondition());
}
doCreateAppendBlob(client, opts, exchange);
}
Aggregations