From 618668dda8458a353e5a483b83722d8fcac8b786 Mon Sep 17 00:00:00 2001 From: "changlin.shi" Date: Mon, 19 Feb 2024 17:10:39 +0800 Subject: [PATCH] =?UTF-8?q?Revert=20"fix:=20=E5=BD=93=E7=BC=BA=E5=B0=91con?= =?UTF-8?q?tent-type=E5=A4=B4=E5=92=8C=E6=96=87=E4=BB=B6=E5=90=8E=E7=BC=80?= =?UTF-8?q?=E6=97=B6=E8=87=AA=E5=8A=A8=E6=A3=80=E6=B5=8Bmime=20type"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 503ae6ad64373a3b6cfa9ff81c595ce3304351e3. --- weed/s3api/filer_multipart.go | 9 +++------ weed/s3api/s3api_object_handlers.go | 2 +- weed/s3api/s3api_object_multipart_handlers.go | 3 +-- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/weed/s3api/filer_multipart.go b/weed/s3api/filer_multipart.go index cbae59fae..fefddf4b2 100644 --- a/weed/s3api/filer_multipart.go +++ b/weed/s3api/filer_multipart.go @@ -99,13 +99,10 @@ func (s3a *S3ApiServer) completeMultipartUpload(input *s3.CompleteMultipartUploa for _, entry := range entries { if strings.HasSuffix(entry.Name, ".part") && !entry.IsDirectory { - partETag, isFirstPart, found := findByPartNumber(entry.Name, completedParts) + partETag, found := findByPartNumber(entry.Name, completedParts) if !found { continue } - if isFirstPart { - mime = entry.GetAttributes().Mime - } entryETag := hex.EncodeToString(entry.Attributes.GetMd5()) if partETag != "" && len(partETag) == 32 && entryETag != "" && entryETag != partETag { glog.Errorf("completeMultipartUpload %s ETag mismatch chunk: %s part: %s", entry.Name, entryETag, partETag) @@ -179,7 +176,7 @@ func (s3a *S3ApiServer) completeMultipartUpload(input *s3.CompleteMultipartUploa return } -func findByPartNumber(fileName string, parts []CompletedPart) (etag string, firstPart, found bool) { +func findByPartNumber(fileName string, parts []CompletedPart) (etag string, found bool) { partNumber, formatErr := strconv.Atoi(fileName[:4]) if formatErr != nil { return @@ -201,7 +198,7 @@ func findByPartNumber(fileName string, parts []CompletedPart) (etag string, firs break } } - return parts[x+y].ETag, partNumber == 1, true + return parts[x+y].ETag, true } func (s3a *S3ApiServer) abortMultipartUpload(input *s3.AbortMultipartUploadInput) (output *s3.AbortMultipartUploadOutput, code s3err.ErrorCode) { diff --git a/weed/s3api/s3api_object_handlers.go b/weed/s3api/s3api_object_handlers.go index 2ba63c784..4d0e374b2 100644 --- a/weed/s3api/s3api_object_handlers.go +++ b/weed/s3api/s3api_object_handlers.go @@ -122,7 +122,7 @@ func (s3a *S3ApiServer) PutObjectHandler(w http.ResponseWriter, r *http.Request) } } else { uploadUrl := s3a.toFilerUrl(bucket, object) - if objectContentType == "" || objectContentType == "application/octet-stream" { + if objectContentType == "" { dataReader = mimeDetect(r, dataReader) } diff --git a/weed/s3api/s3api_object_multipart_handlers.go b/weed/s3api/s3api_object_multipart_handlers.go index 2784208fe..07b6497ae 100644 --- a/weed/s3api/s3api_object_multipart_handlers.go +++ b/weed/s3api/s3api_object_multipart_handlers.go @@ -312,8 +312,7 @@ func (s3a *S3ApiServer) PutObjectPartHandler(w http.ResponseWriter, r *http.Requ uploadUrl := fmt.Sprintf("http://%s%s/%s/%04d.part", s3a.option.Filer.ToHttpAddress(), s3a.genUploadsFolder(bucket), uploadID, partID) - contentType := r.Header.Get("Content-Type") - if partID == 1 && contentType == "" || contentType == "application/octet-stream" { + if partID == 1 && r.Header.Get("Content-Type") == "" { dataReader = mimeDetect(r, dataReader) }