如何从java中删除Google云平台中的bucket?
考虑下面的代码,它允许我从Java创建一个bucket如何从java中删除Google云平台中的bucket?,java,gcp,Java,Gcp,考虑下面的代码,它允许我从Java创建一个bucket package com.lscale.gcp.test1; import com.google.cloud.storage.Bucket; import com.google.cloud.storage.BucketInfo; import com.google.cloud.storage.Storage; import com.google.cloud.storage.StorageOptions; public class Crea
package com.lscale.gcp.test1;
import com.google.cloud.storage.Bucket;
import com.google.cloud.storage.BucketInfo;
import com.google.cloud.storage.Storage;
import com.google.cloud.storage.StorageOptions;
public class CreateBucket {
public static void main(String... args) throws Exception {
// Instantiates a client
Storage storage = StorageOptions.getDefaultInstance().getService();
// The name for the new bucket
String bucketName = Properties.bucketId; // "my-new-bucket";
// Creates the new bucket
Bucket bucket = storage.create(BucketInfo.of(bucketName));
System.out.printf("Bucket %s created.%n", bucket.getName());
}
}
问题是:如何使用java代码删除它?首先,bucket必须为空 然后你可以做: storage.bucket().delete(Properties.bucketId.execute()) 其中存储是com.google.api.services.storage 我希望有帮助!:)