[s3] fix s3 test_multipart_get_part (#5476)
* try fix s3 test_multipart_get_part * add passed s3 tests * fix SeaweedFSUploadId * rm spaces * convert part request to range * add passed s3 tests of multipart
This commit is contained in:
committed by
GitHub
parent
8833745fbc
commit
33537ae29f
@@ -3,6 +3,8 @@ package weed_server
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/base64"
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
@@ -132,7 +134,7 @@ func (fs *FilerServer) GetOrHeadHandler(w http.ResponseWriter, r *http.Request)
|
||||
return
|
||||
}
|
||||
// inform S3 API this is a user created directory key object
|
||||
w.Header().Set(s3_constants.X_SeaweedFS_Header_Directory_Key, "true")
|
||||
w.Header().Set(s3_constants.SeaweedFSIsDirectoryKey, "true")
|
||||
}
|
||||
|
||||
if isForDirectory && entry.Attr.Mime != s3_constants.FolderMimeType {
|
||||
@@ -158,7 +160,22 @@ func (fs *FilerServer) GetOrHeadHandler(w http.ResponseWriter, r *http.Request)
|
||||
return
|
||||
}
|
||||
|
||||
etag := filer.ETagEntry(entry)
|
||||
var etag string
|
||||
if partNumber, errNum := strconv.Atoi(r.Header.Get(s3_constants.SeaweedFSPartNumber)); errNum == nil {
|
||||
if len(entry.Chunks) < partNumber {
|
||||
stats.FilerHandlerCounter.WithLabelValues(stats.ErrorReadChunk).Inc()
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
w.Write([]byte("InvalidPart"))
|
||||
return
|
||||
}
|
||||
w.Header().Set(s3_constants.AmzMpPartsCount, strconv.Itoa(len(entry.Chunks)))
|
||||
partChunk := entry.GetChunks()[partNumber-1]
|
||||
md5, _ := base64.StdEncoding.DecodeString(partChunk.ETag)
|
||||
etag = hex.EncodeToString(md5)
|
||||
r.Header.Set("Range", fmt.Sprintf("bytes=%d-%d", partChunk.Offset, uint64(partChunk.Offset)+partChunk.Size-1))
|
||||
} else {
|
||||
etag = filer.ETagEntry(entry)
|
||||
}
|
||||
w.Header().Set("Accept-Ranges", "bytes")
|
||||
|
||||
// mime type
|
||||
@@ -207,7 +224,6 @@ func (fs *FilerServer) GetOrHeadHandler(w http.ResponseWriter, r *http.Request)
|
||||
|
||||
filename := entry.Name()
|
||||
adjustPassthroughHeaders(w, r, filename)
|
||||
|
||||
totalSize := int64(entry.Size())
|
||||
|
||||
if r.Method == "HEAD" {
|
||||
|
||||
Reference in New Issue
Block a user