本文整理汇总了Java中com.google.api.services.storage.model.Bucket.setLocation方法的典型用法代码示例。如果您正苦于以下问题:Java Bucket.setLocation方法的具体用法?Java Bucket.setLocation怎么用?Java Bucket.setLocation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.api.services.storage.model.Bucket
的用法示例。
在下文中一共展示了Bucket.setLocation方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createBucket
import com.google.api.services.storage.model.Bucket; //导入方法依赖的package包/类
private static Bucket createBucket(Storage storage, String projectId, String locationId, String bucketId) {
try {
Bucket bucket = new Bucket()
.setLocation(locationId)
.setName(bucketId)
.setVersioning(new Bucket.Versioning().setEnabled(true));
if (!StringUtils.isEmpty(locationId)) {
bucket.setLocation(locationId);
}
return storage.buckets().insert(projectId, bucket).execute();
} catch (IOException e) {
throw new RuntimeException("Unable to create bucket", e);
}
}
示例2: create
import com.google.api.services.storage.model.Bucket; //导入方法依赖的package包/类
/**
* See {@link GoogleCloudStorage#create(String, CreateBucketOptions)} for
* details about expected behavior.
*/
@Override
public void create(String bucketName, CreateBucketOptions options)
throws IOException {
LOG.debug("create({})", bucketName);
Preconditions.checkArgument(!Strings.isNullOrEmpty(bucketName),
"bucketName must not be null or empty");
Preconditions.checkNotNull(options, "options must not be null");
Preconditions.checkNotNull(storageOptions.getProjectId(), "projectId must not be null");
Bucket bucket = new Bucket();
bucket.setName(bucketName);
bucket.setLocation(options.getLocation());
bucket.setStorageClass(options.getStorageClass());
Storage.Buckets.Insert insertBucket =
gcs.buckets().insert(storageOptions.getProjectId(), bucket);
// TODO(user): To match the behavior of throwing FileNotFoundException for 404, we probably
// want to throw org.apache.commons.io.FileExistsException for 409 here.
try {
ResilientOperation.retry(
ResilientOperation.getGoogleRequestCallable(insertBucket),
backOffFactory.newBackOff(),
rateLimitedRetryDeterminer,
IOException.class,
sleeper);
} catch (InterruptedException e) {
throw new IOException(e); // From sleep
}
}
示例3: createTestBucket
import com.google.api.services.storage.model.Bucket; //导入方法依赖的package包/类
/**
* Creates a test bucket based on the given number.
*/
private Bucket createTestBucket(int bucketNumber) {
Bucket b = new Bucket();
String bucketNumberStr = Integer.toString(bucketNumber);
b.setName("bucket" + bucketNumberStr);
b.setTimeCreated(new DateTime(new Date()));
b.setLocation("location");
b.setStorageClass("DRA");
return b;
}