From e5e3387b26e2128d8a40c1c7d768cb2dfc07bd28 Mon Sep 17 00:00:00 2001 From: wangmingshuai <736808191@qq.com> Date: Tue, 1 Sep 2015 16:01:22 +0800 Subject: [PATCH] S3 Compatible:support RadosGW when using goamz in docker registry --- s3/multi.go | 6 ++++++ s3/s3.go | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/s3/multi.go b/s3/multi.go index ff454265..d905f565 100644 --- a/s3/multi.go +++ b/s3/multi.go @@ -8,6 +8,7 @@ import ( "encoding/xml" "errors" "io" + "net/http" "net/url" "sort" "strconv" @@ -428,6 +429,11 @@ func (m *Multi) Complete(parts []Part) error { payload: bytes.NewReader(data), } var resp completeUploadResp + if m.Bucket.Region.Name == "generic" { + headers := make(http.Header) + headers.Add("Content-Length", strconv.FormatInt(int64(len(data)), 10)) + req.headers = headers + } err := m.Bucket.S3.query(req, &resp) if shouldRetry(err) && attempt.HasNext() { continue diff --git a/s3/s3.go b/s3/s3.go index dd313025..990a6537 100644 --- a/s3/s3.go +++ b/s3/s3.go @@ -1111,7 +1111,9 @@ func (s3 *S3) setupHttpRequest(req *request) (*http.Request, error) { if err != nil { return nil, err } - u.Opaque = fmt.Sprintf("//%s%s", u.Host, partiallyEscapedPath(u.Path)) + if s3.Region.Name != "generic" { + u.Opaque = fmt.Sprintf("//%s%s", u.Host, partiallyEscapedPath(u.Path)) + } hreq := http.Request{ URL: u,