mirror of
https://github.com/minio/minio.git
synced 2024-12-24 06:05:55 -05:00
parent
2f373684f5
commit
51d1e6f75b
@ -660,7 +660,7 @@ func (fs fsObjects) CompleteMultipartUpload(bucket string, object string, upload
|
||||
defer appendPathLock.Unlock()
|
||||
|
||||
// Calculate s3 compatible md5sum for complete multipart.
|
||||
s3MD5, err := getCompleteMultipartMD5(parts...)
|
||||
s3MD5, err := getCompleteMultipartMD5(parts)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
@ -1864,7 +1864,7 @@ func testObjectCompleteMultipartUpload(obj ObjectLayer, instanceType string, t T
|
||||
},
|
||||
},
|
||||
}
|
||||
s3MD5, err := getCompleteMultipartMD5(inputParts[3].parts...)
|
||||
s3MD5, err := getCompleteMultipartMD5(inputParts[3].parts)
|
||||
if err != nil {
|
||||
t.Fatalf("Obtaining S3MD5 failed")
|
||||
}
|
||||
|
@ -877,7 +877,6 @@ func (api objectAPIHandlers) CompleteMultipartUploadHandler(w http.ResponseWrite
|
||||
}
|
||||
|
||||
md5Sum, err = objectAPI.CompleteMultipartUpload(bucket, object, uploadID, completeParts)
|
||||
|
||||
if err != nil {
|
||||
err = errorCause(err)
|
||||
errorIf(err, "Unable to complete multipart upload.")
|
||||
@ -903,6 +902,9 @@ func (api objectAPIHandlers) CompleteMultipartUploadHandler(w http.ResponseWrite
|
||||
return
|
||||
}
|
||||
|
||||
// Set etag.
|
||||
w.Header().Set("ETag", "\""+md5Sum+"\"")
|
||||
|
||||
// Write success response.
|
||||
w.Write(encodedSuccessResponse)
|
||||
w.(http.Flusher).Flush()
|
||||
|
@ -1507,7 +1507,7 @@ func testAPICompleteMultipartHandler(obj ObjectLayer, instanceType, bucketName s
|
||||
}
|
||||
|
||||
// on successful complete multipart operation the s3MD5 for the parts uploaded will be returned.
|
||||
s3MD5, err := getCompleteMultipartMD5(inputParts[3].parts...)
|
||||
s3MD5, err := getCompleteMultipartMD5(inputParts[3].parts)
|
||||
if err != nil {
|
||||
t.Fatalf("Obtaining S3MD5 failed")
|
||||
}
|
||||
|
@ -141,7 +141,7 @@ func getUUID() (uuidStr string) {
|
||||
}
|
||||
|
||||
// Create an s3 compatible MD5sum for complete multipart transaction.
|
||||
func getCompleteMultipartMD5(parts ...completePart) (string, error) {
|
||||
func getCompleteMultipartMD5(parts []completePart) (string, error) {
|
||||
var finalMD5Bytes []byte
|
||||
for _, part := range parts {
|
||||
md5Bytes, err := hex.DecodeString(part.ETag)
|
||||
|
@ -158,7 +158,7 @@ func TestGetCompleteMultipartMD5(t *testing.T) {
|
||||
}
|
||||
|
||||
for i, test := range testCases {
|
||||
result, err := getCompleteMultipartMD5(test.parts...)
|
||||
result, err := getCompleteMultipartMD5(test.parts)
|
||||
if result != test.expectedResult {
|
||||
t.Fatalf("test %d failed: expected: result=%v, got=%v", i+1, test.expectedResult, result)
|
||||
}
|
||||
|
@ -2503,5 +2503,12 @@ func (s *TestSuiteCommon) TestObjectMultipart(c *C) {
|
||||
c.Assert(err, IsNil)
|
||||
// verify whether complete multipart was successful.
|
||||
c.Assert(response.StatusCode, Equals, http.StatusOK)
|
||||
|
||||
var parts []completePart
|
||||
for _, part := range completeUploads.Parts {
|
||||
part.ETag = strings.Trim(part.ETag, "\"")
|
||||
parts = append(parts, part)
|
||||
}
|
||||
etag, err := getCompleteMultipartMD5(parts)
|
||||
c.Assert(err, IsNil)
|
||||
c.Assert(strings.Trim(response.Header.Get("Etag"), "\""), Equals, etag)
|
||||
}
|
||||
|
@ -664,7 +664,7 @@ func (xl xlObjects) CompleteMultipartUpload(bucket string, object string, upload
|
||||
return "", traceError(InvalidUploadID{UploadID: uploadID})
|
||||
}
|
||||
// Calculate s3 compatible md5sum for complete multipart.
|
||||
s3MD5, err := getCompleteMultipartMD5(parts...)
|
||||
s3MD5, err := getCompleteMultipartMD5(parts)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user