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


Java CloudBlobContainer.delete方法代码示例

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


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

示例1: validateWasbFileSystem

import com.microsoft.azure.storage.blob.CloudBlobContainer; //导入方法依赖的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

示例2: deleteContainer

import com.microsoft.azure.storage.blob.CloudBlobContainer; //导入方法依赖的package包/类
@NotNull
public static String deleteContainer(@NotNull final StorageInputs inputs) throws Exception {
    final CloudBlobClient blobClient = getCloudBlobClient(inputs);
    final CloudBlobContainer container = blobClient.getContainerReference(inputs.getContainerName());
    container.delete();
    return inputs.getContainerName();
}
 
开发者ID:CloudSlang,项目名称:cs-actions,代码行数:8,代码来源:StorageServiceImpl.java

示例3: create

import com.microsoft.azure.storage.blob.CloudBlobContainer; //导入方法依赖的package包/类
public static AzureBlobStorageTestAccount create(String containerNameSuffix,
    EnumSet<CreateOptions> createOptions, Configuration initialConfiguration)
    throws Exception {
  saveMetricsConfigFile();
  NativeAzureFileSystem fs = null;
  CloudBlobContainer container = null;
  Configuration conf = createTestConfiguration(initialConfiguration);
  configurePageBlobDir(conf);
  configureAtomicRenameDir(conf);
  CloudStorageAccount account = createTestAccount(conf);
  if (account == null) {
    return null;
  }
  fs = new NativeAzureFileSystem();
  String containerName = String.format("wasbtests-%s-%tQ%s",
      System.getProperty("user.name"), new Date(), containerNameSuffix);
  container = account.createCloudBlobClient().getContainerReference(
      containerName);
  if (createOptions.contains(CreateOptions.CreateContainer)) {
    container.create();
  }
  String accountName = conf.get(TEST_ACCOUNT_NAME_PROPERTY_NAME);
  if (createOptions.contains(CreateOptions.UseSas)) {
    String sas = generateSAS(container,
        createOptions.contains(CreateOptions.Readonly));
    if (!createOptions.contains(CreateOptions.CreateContainer)) {
      // The caller doesn't want the container to be pre-created,
      // so delete it now that we have generated the SAS.
      container.delete();
    }
    // Remove the account key from the configuration to make sure we don't
    // cheat and use that.
    conf.set(ACCOUNT_KEY_PROPERTY_NAME + accountName, "");
    // Set the SAS key.
    conf.set(SAS_PROPERTY_NAME + containerName + "." + accountName, sas);
  }

  // Check if throttling is turned on and set throttling parameters
  // appropriately.
  if (createOptions.contains(CreateOptions.useThrottling)) {
    conf.setBoolean(KEY_DISABLE_THROTTLING, false);
  } else {
    conf.setBoolean(KEY_DISABLE_THROTTLING, true);
  }

  // Set account URI and initialize Azure file system.
  URI accountUri = createAccountUri(accountName, containerName);
  fs.initialize(accountUri, conf);

  // Create test account initializing the appropriate member variables.
  //
  AzureBlobStorageTestAccount testAcct =
      new AzureBlobStorageTestAccount(fs, account, container);

  return testAcct;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:57,代码来源:AzureBlobStorageTestAccount.java

示例4: testFileCopyFromBlobWithSasAndSnapshot

import com.microsoft.azure.storage.blob.CloudBlobContainer; //导入方法依赖的package包/类
@Test
public void testFileCopyFromBlobWithSasAndSnapshot()
        throws URISyntaxException, StorageException, InterruptedException, IOException, InvalidKeyException {
    String blobName = BlobTestHelper.generateRandomBlobNameWithPrefix("testblob");
    CloudBlobContainer container = TestHelper.createCloudBlobClient().getContainerReference(BlobTestHelper.generateRandomContainerName());
    container.createIfNotExists();
    CloudBlockBlob source = container.getBlockBlobReference(blobName);
    String data = "String data";
    source.uploadText(data, Constants.UTF8_CHARSET, null, null, null);

    byte[] buffer = BlobTestHelper.getRandomBuffer(512);
    ByteArrayInputStream stream = new ByteArrayInputStream(buffer);
    source.upload(stream, buffer.length);
    source.getMetadata().put("Test", "value");
    source.uploadMetadata();

    SharedAccessFilePolicy policy = createSharedAccessPolicy(
            EnumSet.of(SharedAccessFilePermissions.READ, SharedAccessFilePermissions.WRITE,
                  SharedAccessFilePermissions.LIST, SharedAccessFilePermissions.DELETE), 5000);

    CloudFile copy = this.share.getRootDirectoryReference().getFileReference("copy");
    String sasToken = copy.generateSharedAccessSignature(policy, null);
    CloudFile copySas = new CloudFile(new URI(copy.getUri().toString() + "?" + sasToken));
    
    // Generate account SAS for the source
    // Cannot generate a SAS directly on a snapshot and the SAS for the destination is only for the destination
    SharedAccessAccountPolicy accountPolicy = new SharedAccessAccountPolicy();
    accountPolicy.setPermissions(EnumSet.of(SharedAccessAccountPermissions.READ, SharedAccessAccountPermissions.WRITE));
    accountPolicy.setServices(EnumSet.of(SharedAccessAccountService.BLOB));
    accountPolicy.setResourceTypes(EnumSet.of(SharedAccessAccountResourceType.OBJECT, SharedAccessAccountResourceType.CONTAINER));
    accountPolicy.setSharedAccessExpiryTime(policy.getSharedAccessExpiryTime());
    final CloudBlobClient sasClient = TestHelper.createCloudBlobClient(accountPolicy, false);

    CloudBlockBlob snapshot = (CloudBlockBlob) source.createSnapshot();
    CloudBlockBlob sasBlob = (CloudBlockBlob) sasClient.getContainerReference(container.getName())
            .getBlobReferenceFromServer(snapshot.getName(), snapshot.getSnapshotID(), null, null, null);
    sasBlob.exists();

    String copyId = copySas.startCopy(BlobTestHelper.defiddler(sasBlob));
    FileTestHelper.waitForCopy(copySas);
    
    copySas.downloadAttributes();
    FileProperties prop1 = copySas.getProperties();
    BlobProperties prop2 = sasBlob.getProperties();

    assertEquals(prop1.getCacheControl(), prop2.getCacheControl());
    assertEquals(prop1.getContentEncoding(), prop2.getContentEncoding());
    assertEquals(prop1.getContentDisposition(),
            prop2.getContentDisposition());
    assertEquals(prop1.getContentLanguage(), prop2.getContentLanguage());
    assertEquals(prop1.getContentMD5(), prop2.getContentMD5());
    assertEquals(prop1.getContentType(), prop2.getContentType());

    assertEquals("value", copySas.getMetadata().get("Test"));
    assertEquals(copyId, copySas.getCopyState().getCopyId());

    snapshot.delete();
    source.delete();
    copySas.delete();
    container.delete();
}
 
开发者ID:Azure,项目名称:azure-storage-android,代码行数:62,代码来源:FileSasTests.java


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