存储桶插入失败,错误代码为400

use*_*419 7 google-cloud-storage

这是代码段:

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;
 }
Run Code Online (Sandbox Code Playgroud)

抛出:tryCreateBucket中的异常:

com.google.api.client.googleapis.json.GoogleJsonResponseException: 400 Bad Request
{
  "code" : 400,
  "errors" : [ {
    "domain" : "global",
    "message" : "Invalid Value",
    "reason" : "invalid"
  } ],
  "message" : "Invalid Value"
}
Run Code Online (Sandbox Code Playgroud)

有关如何解决这个问题的任何想法?

谢谢/ VK

Mik*_*rtz 7

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