0

我正在编写示例代码以在 Google Cloud Storage 中创建存储桶。我正在关注链接中编写的这个 XML API -

PUT / HTTP/1.1
Host: helloworld.storage.googleapis.com
Accept-Encoding: identity
Date: Fri, 01 Apr 2011 21:52:39 GMT
Content-Length: 92
x-goog-api-version: 2
x-goog-project-id: 123456789123
Authorization: Bearer 1/zVNpoQNsOSxZKqOZgckhpQ

<xml version="1.0" encoding="UTF-8"?>
<CreateBucketConfiguration>
  <LocationConstraint>EU</LocationConstraint>
</CreateBucketConfiguration> 

谷歌存储位置 -

EU - European Union
US - United States
US-EAST1 - Eastern United States
US-EAST2 - Eastern United States
US-EAST3 - Eastern United States
US-CENTRAL1 - Central United States
US-CENTRAL2 - Central United States
US-WEST1 - Western United States

如果我在<LocationConstraint>标签中提供 US 和 EU,我可以创建 Bucket。但是,如果我给出这两个以外的任何其他内容,比如说 - US-CENTRAL2<LocationConstraint>标记为 -

<xml version="1.0" encoding="UTF-8"?>
<CreateBucketConfiguration>
   <LocationConstraint>US-CENTRAL2</LocationConstraint>
</CreateBucketConfiguration> 

然后在创建存储桶时,此代码会引发错误 -

Encountered too many Internal Server errors (6), aborting request. PUT '/mybucket/' on Host 'commondatastorage.googleapis.com' @ 'Fri, 16 Aug 2013 09:08:21 GMT' -- ResponseCode: 500, ResponseStatus: Internal Server Error

我如何在除美国和欧盟位置之外的其余六个部分创建存储桶?API有变化吗??

谢谢您的帮助,

尼拉姆夏尔马

4

1 回答 1

3

<StorageClass>为了在美国和欧盟以外的其他位置创建存储桶,我们需要通过添加一个带有 DURABLE_REDUCED_AVAILABILITY 值的标签来发送 PUT Bucket 请求 -

<xml version="1.0" encoding="UTF-8"?>
<CreateBucketConfiguration>
   <LocationConstraint>US-CENTRAL2</LocationConstraint>
   <StorageClass>DURABLE_REDUCED_AVAILABILITY</StorageClass>
</CreateBucketConfiguration> 

添加这个标签解决了我的问题。

于 2013-08-16T12:04:02.130 回答