use of com.microsoft.azure.storage.blob.CloudBlockBlob in project druid by druid-io.
the class AzureStorage method uploadBlob.
public void uploadBlob(final File file, final String containerName, final String blobPath) throws IOException, StorageException, URISyntaxException {
CloudBlobContainer container = getCloudBlobContainer(containerName);
try (FileInputStream stream = new FileInputStream(file)) {
CloudBlockBlob blob = container.getBlockBlobReference(blobPath);
blob.upload(stream, file.length());
}
}
use of com.microsoft.azure.storage.blob.CloudBlockBlob in project elasticsearch by elastic.
the class AzureStorageServiceImpl method getInputStream.
@Override
public InputStream getInputStream(String account, LocationMode mode, String container, String blob) throws URISyntaxException, StorageException {
logger.trace("reading container [{}], blob [{}]", container, blob);
CloudBlobClient client = this.getSelectedClient(account, mode);
CloudBlockBlob blockBlobReference = client.getContainerReference(container).getBlockBlobReference(blob);
return SocketAccess.doPrivilegedException(blockBlobReference::openInputStream);
}
use of com.microsoft.azure.storage.blob.CloudBlockBlob in project elasticsearch by elastic.
the class AzureStorageServiceImpl method blobExists.
@Override
public boolean blobExists(String account, LocationMode mode, String container, String blob) throws URISyntaxException, StorageException {
// Container name must be lower case.
CloudBlobClient client = this.getSelectedClient(account, mode);
CloudBlobContainer blobContainer = client.getContainerReference(container);
if (blobContainer.exists()) {
CloudBlockBlob azureBlob = blobContainer.getBlockBlobReference(blob);
return SocketAccess.doPrivilegedException(azureBlob::exists);
}
return false;
}
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