diff --git a/backend.go b/backend.go index f5334b1..aba93b7 100644 --- a/backend.go +++ b/backend.go @@ -318,7 +318,7 @@ type MultipartBackend interface { ListParts(bucket, object string, uploadID UploadID, marker int, limit int64) (*ListMultipartUploadPartsResult, error) AbortMultipartUpload(bucket, object string, id UploadID) error - CompleteMultipartUpload(bucket, object string, id UploadID, input *CompleteMultipartUploadRequest) (*CompleteMultipartResult, error) + CompleteMultipartUpload(bucket, object string, id UploadID, input *CompleteMultipartUploadRequest) (*CompleteMultipartUploadResult, error) } // CopyObject is a helper function useful for quickly implementing CopyObject on diff --git a/gofakes3.go b/gofakes3.go index 8fe0456..66c0284 100644 --- a/gofakes3.go +++ b/gofakes3.go @@ -788,9 +788,12 @@ func (g *GoFakeS3) copyObject(bucket, object string, meta map[string]string, w h if srcObj.VersionID != "" { w.Header().Set("x-amz-version-id", string(srcObj.VersionID)) } - if result.ETag != "" { - w.Header().Set("ETag", result.ETag) + + etag := result.ETag + if etag == "" { + etag = formatETag(hex.EncodeToString(srcObj.Hash)) } + w.Header().Set("ETag", etag) return g.xmlEncoder(w).Encode(result) } @@ -987,7 +990,7 @@ func (g *GoFakeS3) completeMultipartUpload(bucket, object string, uploadID Uploa w.Header().Set("x-amz-version-id", string(res.VersionID)) } - return g.xmlEncoder(w).Encode(&CompleteMultipartUploadResult{ + return g.xmlEncoder(w).Encode(&CompleteMultipartUploadResponse{ ETag: res.ETag, Bucket: bucket, Key: object, diff --git a/messages.go b/messages.go index 6d51a2f..1075421 100644 --- a/messages.go +++ b/messages.go @@ -69,7 +69,7 @@ func (c CompleteMultipartUploadRequest) partIDs() []int { return inParts } -type CompleteMultipartUploadResult struct { +type CompleteMultipartUploadResponse struct { Location string `xml:"Location"` Bucket string `xml:"Bucket"` Key string `xml:"Key"` @@ -369,7 +369,7 @@ type UploadPartResult struct { ETag string `xml:"ETag,omitempty"` } -type CompleteMultipartResult struct { +type CompleteMultipartUploadResult struct { // If versioning is enabled on the bucket, this should be set to the // created version ID. If versioning is not enabled, this should be // empty. diff --git a/uploader.go b/uploader.go index c77cb85..ad47be3 100644 --- a/uploader.go +++ b/uploader.go @@ -403,7 +403,7 @@ func (u *uploader) UploadPart(bucket, object string, id UploadID, partNumber int return &UploadPartResult{ETag: formatETag(etag)}, nil } -func (u *uploader) CompleteMultipartUpload(bucket, object string, id UploadID, input *CompleteMultipartUploadRequest) (*CompleteMultipartResult, error) { +func (u *uploader) CompleteMultipartUpload(bucket, object string, id UploadID, input *CompleteMultipartUploadRequest) (*CompleteMultipartUploadResult, error) { mpu, err := u.getUnlocked(bucket, object, id) if err != nil { return nil, err @@ -457,7 +457,7 @@ func (u *uploader) CompleteMultipartUpload(bucket, object string, id UploadID, i // if getUnlocked succeeded, so will this: u.buckets[bucket].remove(id) - return &CompleteMultipartResult{ + return &CompleteMultipartUploadResult{ VersionID: result.VersionID, ETag: etag, }, nil