com.google.cloud.storage.Bucket.delete()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(1.6k)|赞(0)|评价(0)|浏览(132)

本文整理了Java中com.google.cloud.storage.Bucket.delete()方法的一些代码示例,展示了Bucket.delete()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bucket.delete()方法的具体详情如下:
包路径:com.google.cloud.storage.Bucket
类名称:Bucket
方法名:delete

Bucket.delete介绍

[英]Deletes this bucket.

Example of deleting the bucket, if its metageneration matches the Bucket#getMetageneration() value, otherwise a StorageException is thrown.

boolean deleted = bucket.delete(BucketSourceOption.metagenerationMatch());else  
// the bucket was not found 
} 
}

[中]删除此存储桶。
删除bucket的示例,如果其元生成与bucket#getMetageneration()值匹配,则抛出StorageException。

boolean deleted = bucket.delete(BucketSourceOption.metagenerationMatch());else  
// the bucket was not found 
} 
}

代码示例

代码示例来源:origin: googleapis/google-cloud-java

/**
 * Example of deleting the bucket, if its metageneration matches the {@link
 * Bucket#getMetageneration()} value, otherwise a {@link StorageException} is thrown.
 */
// [TARGET delete(BucketSourceOption...)]
public boolean delete() {
 // [START delete]
 boolean deleted = bucket.delete(BucketSourceOption.metagenerationMatch());
 if (deleted) {
  // the bucket was deleted
 } else {
  // the bucket was not found
 }
 // [END delete]
 return deleted;
}

代码示例来源:origin: googleapis/google-cloud-java

@Test
public void testDelete() throws Exception {
 initializeExpectedBucket(4);
 expect(storage.getOptions()).andReturn(mockOptions);
 expect(storage.delete(BUCKET_INFO.getName())).andReturn(true);
 replay(storage);
 initializeBucket();
 assertTrue(bucket.delete());
}

代码示例来源:origin: io.konig/konig-gcp-common

private void deleteBucket(Bucket bucket) {
  if (bucket != null) {
  
    Page<Blob> page = bucket.list();
    
    for (Blob blob : page.iterateAll()) {
      blob.delete();
    }
    bucket.delete();
  }
  
}

相关文章