从S3服务器返回以下响应:
<Error>
<Code>BucketAlreadyOwnedByYou</Code>
<Message>Your previous request to create the named bucket succeeded and you already own it.</Message>
<BucketName>newbucket</BucketName>
<Resource>/newbucket</Resource>
<RequestId>15C79B745D6D5C78</RequestId>
<HostId>1c8c1a3a-fe7a-472a-a401-b57d6997aa9e</HostId>
</Error>
如何在出现错误时使用aws-sdk-go
从S3服务器获取xml响应?我想要所有的xml响应。
func createBucket(s *s3.S3) {
out, err := s.CreateBucket(&s3.CreateBucketInput{
Bucket: aws.String("newbucket"),
})
}
在我的情况下使用err
是不够的。
谢谢您的时间。
答案 0 :(得分:0)
我找到了方法:
head := s3.GetObjectInput{Bucket: &bucket, Key: aws.String("a")}
req, _ := fs.s3.GetObjectRequest(&head)
req.Handlers.UnmarshalMeta.PushBack(func(req *request.Request) {
defer req.HTTPResponse.Body.Close()
//req.HTTPResponse.Header['x-amz-bucket-region']
buf, err := ioutil.ReadAll(req.HTTPResponse.Body)
fmt.Printf("err: %v", string(buf))
return
})
req.Send()
转到https://github.com/aws/aws-sdk-go/issues/542#issuecomment-180893732了解更多详细信息。