当前位置: 首页>>代码示例>>Java>>正文


Java CloudStorageAccount.createCloudBlobClient方法代码示例

本文整理汇总了Java中com.microsoft.azure.storage.CloudStorageAccount.createCloudBlobClient方法的典型用法代码示例。如果您正苦于以下问题:Java CloudStorageAccount.createCloudBlobClient方法的具体用法?Java CloudStorageAccount.createCloudBlobClient怎么用?Java CloudStorageAccount.createCloudBlobClient使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.microsoft.azure.storage.CloudStorageAccount的用法示例。


在下文中一共展示了CloudStorageAccount.createCloudBlobClient方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: uploadToAzureStorage

import com.microsoft.azure.storage.CloudStorageAccount; //导入方法依赖的package包/类
/**
 * Upload image file to Azure storage with specified name.
 *
 * @param file     image file object
 * @param fileName specified file name
 * @return relative path of the created image blob
 */
public String uploadToAzureStorage(ApplicationContext applicationContext, MultipartFile file, String fileName) {
    String uri = null;

    try {
        CloudStorageAccount storageAccount =
                (CloudStorageAccount) applicationContext.getBean("cloudStorageAccount");
        CloudBlobClient blobClient = storageAccount.createCloudBlobClient();

        setupContainer(blobClient, this.thumbnailImageContainer);
        CloudBlobContainer originalImageContainer = setupContainer(blobClient, this.originalImageContainer);

        if (originalImageContainer != null) {
            CloudBlockBlob blob = originalImageContainer.getBlockBlobReference(fileName);
            blob.upload(file.getInputStream(), file.getSize());

            uri = blob.getUri().getPath();
        }
    } catch (Exception e) {
        e.printStackTrace();
        logger.error("Error uploading image: " + e.getMessage());
    }

    return uri;
}
 
开发者ID:Microsoft,项目名称:movie-db-java-on-azure,代码行数:32,代码来源:AzureStorageUploader.java

示例2: createClient

import com.microsoft.azure.storage.CloudStorageAccount; //导入方法依赖的package包/类
void createClient(AzureStorageSettings azureStorageSettings) {
    try {
        logger.trace("creating new Azure storage client using account [{}], key [{}]",
            azureStorageSettings.getAccount(), azureStorageSettings.getKey());

        String storageConnectionString =
            "DefaultEndpointsProtocol=https;"
                + "AccountName=" + azureStorageSettings.getAccount() + ";"
                + "AccountKey=" + azureStorageSettings.getKey();

        // Retrieve storage account from connection-string.
        CloudStorageAccount storageAccount = CloudStorageAccount.parse(storageConnectionString);

        // Create the blob client.
        CloudBlobClient client = storageAccount.createCloudBlobClient();

        // Register the client
        this.clients.put(azureStorageSettings.getAccount(), client);
    } catch (Exception e) {
        logger.error("can not create azure storage client: {}", e.getMessage());
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:23,代码来源:AzureStorageServiceImpl.java

示例3: setUpStorageAccount

import com.microsoft.azure.storage.CloudStorageAccount; //导入方法依赖的package包/类
private static CloudBlobContainer setUpStorageAccount(String connectionString, String containerName) {
    try {
        CloudStorageAccount account = CloudStorageAccount.parse(connectionString);
        // Create a blob service client
        CloudBlobClient blobClient = account.createCloudBlobClient();
        CloudBlobContainer container = blobClient.getContainerReference(containerName);
        container.createIfNotExists();
        BlobContainerPermissions containerPermissions = new BlobContainerPermissions();
        // Include public access in the permissions object
        containerPermissions.setPublicAccess(BlobContainerPublicAccessType.CONTAINER);
        // Set the permissions on the container
        container.uploadPermissions(containerPermissions);
        return container;
    } catch (StorageException | URISyntaxException | InvalidKeyException e) {
        throw new RuntimeException(e);
    }

}
 
开发者ID:Azure,项目名称:azure-libraries-for-java,代码行数:19,代码来源:ManageLinuxWebAppStorageAccountConnection.java

示例4: getCloudBlobContainer

import com.microsoft.azure.storage.CloudStorageAccount; //导入方法依赖的package包/类
private CloudBlobContainer getCloudBlobContainer(String accountName, String accountKey, String containerName) {
  CloudBlobContainer container = null;

  if (StringUtils.isNotBlank(containerName)) {
    final String storageConnectionString = "DefaultEndpointsProtocol=https"
      + ";AccountName=" + accountName
      + ";AccountKey=" + accountKey;

    try {
      final CloudStorageAccount account = CloudStorageAccount.parse(storageConnectionString);
      CloudBlobClient serviceClient = account.createCloudBlobClient();

      container = serviceClient.getContainerReference(containerName);
      container.createIfNotExists();
    } catch (StorageException | URISyntaxException | InvalidKeyException e) {
      logger.error("Error connecting to container for account {} and container name {}", accountName, containerName, e);
    }
  }

  return container;
}
 
开发者ID:mesosphere,项目名称:dcos-cassandra-service,代码行数:22,代码来源:AzureStorageDriver.java

示例5: init

import com.microsoft.azure.storage.CloudStorageAccount; //导入方法依赖的package包/类
@Override
public void init() throws Exception {
    super.init();

    // Validate configuration
    // Can throw IAEs
    this.validateConfiguration();

    try {
        StorageCredentials credentials = new StorageCredentialsAccountAndKey(storage_account_name, storage_access_key);
        CloudStorageAccount storageAccount = new CloudStorageAccount(credentials, use_https);
        CloudBlobClient blobClient = storageAccount.createCloudBlobClient();
        containerReference = blobClient.getContainerReference(container);
        boolean created = containerReference.createIfNotExists();

        if (created) {
            log.info("Created container named '%s'.", container);
        } else {
            log.debug("Using existing container named '%s'.", container);
        }

    } catch (Exception ex) {
        log.error("Error creating a storage client! Check your configuration.");
        throw ex;
    }
}
 
开发者ID:jgroups-extras,项目名称:jgroups-azure,代码行数:27,代码来源:AZURE_PING.java

示例6: testCreateContainer

import com.microsoft.azure.storage.CloudStorageAccount; //导入方法依赖的package包/类
@Before
public void testCreateContainer() {
    try {
        // Retrieve storage account from connection-string.
        CloudStorageAccount storageAccount = CloudStorageAccount.parse(storageConnectionString);

        // Create the blob client.
        CloudBlobClient blobClient = storageAccount.createCloudBlobClient();

        // Get a reference to a container.
        // The container name must be lower case
        container = blobClient.getContainerReference(containerName);

        // Create the container if it does not exist.
        container.createIfNotExists();
    } catch (Exception e) {
        // Output the stack trace.
        e.printStackTrace();
    }
}
 
开发者ID:dzh,项目名称:jframe,代码行数:21,代码来源:TestBlobService.java

示例7: validateWasbFileSystem

import com.microsoft.azure.storage.CloudStorageAccount; //导入方法依赖的package包/类
private void validateWasbFileSystem(FileSystem fileSystem, String fileSystemType) throws URISyntaxException, InvalidKeyException, StorageException {
    String accountName = fileSystem.getParameter(WasbFileSystemConfiguration.ACCOUNT_NAME, String.class);
    String accountKey = fileSystem.getParameter(WasbFileSystemConfiguration.ACCOUNT_KEY, String.class);
    String connectionString = "DefaultEndpointsProtocol=https;AccountName=" + accountName + ";AccountKey=" + accountKey;
    CloudStorageAccount storageAccount = CloudStorageAccount.parse(connectionString);
    CloudBlobClient blobClient = storageAccount.createCloudBlobClient();
    CloudBlobContainer containerReference = blobClient.getContainerReference(TEST_CONTAINER + System.nanoTime());
    try {
        containerReference.createIfNotExists();
        containerReference.delete();
    } catch (StorageException e) {
        if (e.getCause() instanceof UnknownHostException) {
            throw new CloudConnectorException("The provided account does not belong to a valid storage account");
        }
    }
}
 
开发者ID:hortonworks,项目名称:cloudbreak,代码行数:17,代码来源:AzureSetup.java

示例8: getContainer

import com.microsoft.azure.storage.CloudStorageAccount; //导入方法依赖的package包/类
private CloudBlobContainer getContainer() throws Exception {
    // Retrieve storage account from connection-string.

    CloudStorageAccount storageAccount = CloudStorageAccount
            .parse(storageConnectionString);

    // Create the blob client.
    CloudBlobClient blobClient = storageAccount.createCloudBlobClient();
    Timber.d(blobClient.getEndpoint().toString());
    // Get a reference to a container.
    // The container name must be lower case
    CloudBlobContainer container = blobClient.getContainerReference(CONTAINER_NAME);

    return container;
}
 
开发者ID:BANKEX,项目名称:smart-asset-iot-android-demo,代码行数:16,代码来源:ImageManager.java

示例9: setAzureBlobClient

import com.microsoft.azure.storage.CloudStorageAccount; //导入方法依赖的package包/类
@SuppressWarnings("unused")
private void setAzureBlobClient(CloudStorageAccount azureStorageAccount) {
	if (azureStorageAccount == null) {
		log.error(LOGGER_KEY + "Azure storage account not available. Unable to Initialize Storage Client.");
		return;
	}
	this.mBlobClient = azureStorageAccount.createCloudBlobClient();
}
 
开发者ID:cmanda,项目名称:axway-b2b-plugins,代码行数:9,代码来源:AzureBlobPluggableTransport.java

示例10: getContainer

import com.microsoft.azure.storage.CloudStorageAccount; //导入方法依赖的package包/类
private static CloudBlobContainer getContainer() throws Exception {
    // Retrieve storage account from connection-string.

    CloudStorageAccount storageAccount = CloudStorageAccount
            .parse(storageConnectionString);

    // Create the blob client.
    CloudBlobClient blobClient = storageAccount.createCloudBlobClient();

    // Get a reference to a container.
    // The container name must be lower case
    CloudBlobContainer container = blobClient.getContainerReference("images");

    return container;
}
 
开发者ID:Azure-Samples,项目名称:storage-blob-android-photo-uploader,代码行数:16,代码来源:ImageManager.java

示例11: AzureStore

import com.microsoft.azure.storage.CloudStorageAccount; //导入方法依赖的package包/类
@SuppressWarnings("resource")
public AzureStore() throws InvalidKeyException, URISyntaxException,
		StorageException, IOException {
	FileReader fileReader = new FileReader("/secret/azure.key");
	BufferedReader bufferedReader = new BufferedReader(fileReader);
	String accountName = bufferedReader.readLine();
	String accountKey = bufferedReader.readLine();
	CloudStorageAccount account = CloudStorageAccount
			.parse("DefaultEndpointsProtocol=http;" + "AccountName="
					+ accountName + ";" + "AccountKey=" + accountKey);
	CloudBlobClient serviceClient = account.createCloudBlobClient();
	container = serviceClient
			.getContainerReference(Constants.AZURE_CONTAINER_NAME);
	container.createIfNotExists();
}
 
开发者ID:darshanmaiya,项目名称:MCSFS,代码行数:16,代码来源:AzureStore.java

示例12: getFromAzureBlobStorage

import com.microsoft.azure.storage.CloudStorageAccount; //导入方法依赖的package包/类
public byte[] getFromAzureBlobStorage(String name) throws Exception {
	CloudStorageAccount storageAccount = CloudStorageAccount.parse(azureConnectionString);
	CloudBlobClient blobClient = storageAccount.createCloudBlobClient();
	CloudBlobContainer container = blobClient.getContainerReference(containerName);
	CloudBlockBlob blob = container.getBlockBlobReference(name);

	ByteArrayOutputStream outStream = new ByteArrayOutputStream();
	blob.download(outStream);
	byte[] image = outStream.toByteArray();
	return image;
}
 
开发者ID:ritazh,项目名称:azure-s3proxy-cf-demo,代码行数:12,代码来源:PhotoLibrary.java

示例13: init

import com.microsoft.azure.storage.CloudStorageAccount; //导入方法依赖的package包/类
/**
 * 初始化
 * @return  初始化成功
 */
private synchronized boolean init() {
	DebugLog.d(TAG, "init()");
	
	if (blobClient != null && queueClient != null) {
		return true;
	}
	
	//先查看缓存
	Configuration configuration = null;
	String azure = configuration.getAzureConf();
	
	Charset charset = Charset.forName("utf-8");
	String result = new String(SymmetricalEncryption.decrypt(Algorithm.AES, Base64.decode(azure.getBytes(charset)), MyApp.getApp().a().getBytes(charset)));
	String[] result2 = result.split("\\|");
	accountName = result2[0];
	String key = result2[1];
	
	CloudStorageAccount account = AzureStorage.getAccount(accountName, key);
	
	if (account != null) {
		blobClient = account.createCloudBlobClient();
		queueClient = account.createCloudQueueClient();
	}
	
	DebugLog.d(TAG, "blobClient = " + blobClient);
	DebugLog.d(TAG, "queueClient = " + queueClient);
	
	return blobClient != null && queueClient != null;
}
 
开发者ID:leleliu008,项目名称:Newton_for_Android_AS,代码行数:34,代码来源:UploadBinder.java

示例14: getFromStorageAccount

import com.microsoft.azure.storage.CloudStorageAccount; //导入方法依赖的package包/类
public byte[] getFromStorageAccount(String name) throws Exception {
	CloudStorageAccount storageAccount = CloudStorageAccount.parse(connectionString);
	CloudBlobClient blobClient = storageAccount.createCloudBlobClient();
	CloudBlobContainer container = blobClient.getContainerReference("images");
	CloudBlockBlob blob = container.getBlockBlobReference(name);

	ByteArrayOutputStream outStream = new ByteArrayOutputStream();
	blob.download(outStream);
	byte[] image = outStream.toByteArray();
	return image;
}
 
开发者ID:adib-samples,项目名称:azure-doge,代码行数:12,代码来源:PhotoLibrary.java

示例15: getSchemaNames

import com.microsoft.azure.storage.CloudStorageAccount; //导入方法依赖的package包/类
@Override
public List<NamedThing> getSchemaNames(RuntimeContainer container) throws IOException {
    List<NamedThing> result = new ArrayList<>();
    try {
        CloudStorageAccount storageAccount = getAzureConnection(container).getCloudStorageAccount();
        CloudBlobClient client = storageAccount.createCloudBlobClient();
        for (CloudBlobContainer c : client.listContainers()) {
            result.add(new SimpleNamedThing(c.getName(), c.getName()));
        }
    } catch (InvalidKeyException | URISyntaxException e) {
        throw new ComponentException(e);
    }
    return result;
}
 
开发者ID:Talend,项目名称:components,代码行数:15,代码来源:AzureStorageSourceOrSink.java


注:本文中的com.microsoft.azure.storage.CloudStorageAccount.createCloudBlobClient方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。