谷歌云存储-Bucket插入失败,错误代码为400



这是代码段:

Bucket newBucket = storage.buckets().insert("MyProject", new Bucket().setName("MyBucket").setLocation("US").setStorageClass("DURABLE_REDUCED_AVAILABILITY")).execute();
 } catch (GoogleJsonResponseException e) {
      System.out.println("Exception in tryCreateBucket: "+e);
      throw e;
 }

它抛出:tryCreateBucket:中出现异常

com.google.api.client.googleapis.json.GoogleJsonResponseException: 400 Bad Request
{
  "code" : 400,
  "errors" : [ {
    "domain" : "global",
    "message" : "Invalid Value",
    "reason" : "invalid"
  } ],
  "message" : "Invalid Value"
}

对如何解决这个问题有什么想法吗?

谢谢/VK

bucket名称必须小写。还有许多其他限制-请参阅https://developers.google.com/storage/docs/bucketnaming#requirements

您的项目名称错误,您需要Google分配的形式为foo-barbar-12345的名称,而不是您给它的普通名称(CloudStorage)

相关内容

最新更新