本文整理汇总了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");
}
}
}
示例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();
}
示例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;
}
示例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();
}