This commit is contained in:
limd 2020-09-23 14:29:53 +08:00
parent 8f9f29b773
commit d506080c36

View file

@ -1,7 +1,6 @@
package s3api package s3api
import ( import (
"crypto/md5"
"fmt" "fmt"
"github.com/chrislusf/seaweedfs/weed/s3api/s3err" "github.com/chrislusf/seaweedfs/weed/s3api/s3err"
"net/http" "net/http"
@ -83,7 +82,7 @@ type CopyPartResult struct {
func (s3a *S3ApiServer) CopyObjectPartHandler(w http.ResponseWriter, r *http.Request) { func (s3a *S3ApiServer) CopyObjectPartHandler(w http.ResponseWriter, r *http.Request) {
// https://docs.aws.amazon.com/AmazonS3/latest/dev/CopyingObjctsUsingRESTMPUapi.html // https://docs.aws.amazon.com/AmazonS3/latest/dev/CopyingObjctsUsingRESTMPUapi.html
// https://docs.aws.amazon.com/AmazonS3/latest/API/API_UploadPartCopy.html // https://docs.aws.amazon.com/AmazonS3/latest/API/API_UploadPartCopy.html
dstBucket, dstObject := getBucketAndObject(r) dstBucket, _ := getBucketAndObject(r)
// Copy source path. // Copy source path.
cpSrcPath, err := url.QueryUnescape(r.Header.Get("X-Amz-Copy-Source")) cpSrcPath, err := url.QueryUnescape(r.Header.Get("X-Amz-Copy-Source"))
@ -128,21 +127,12 @@ func (s3a *S3ApiServer) CopyObjectPartHandler(w http.ResponseWriter, r *http.Req
} }
defer dataReader.Close() defer dataReader.Close()
var etag string etag, errCode := s3a.putToFiler(r, dstUrl, dataReader)
if strings.HasSuffix(srcObject, "/") {
if err := s3a.mkdir(s3a.option.BucketsPath, dstBucket+dstObject, nil); err != nil {
writeErrorResponse(w, s3err.ErrInternalError, r.URL)
return
}
etag = fmt.Sprintf("%x", md5.New().Sum(nil))
} else {
_etag, errCode := s3a.putToFiler(r, dstUrl, dataReader)
etag = _etag
if errCode != s3err.ErrNone { if errCode != s3err.ErrNone {
writeErrorResponse(w, errCode, r.URL) writeErrorResponse(w, errCode, r.URL)
return return
} }
}
setEtag(w, etag) setEtag(w, etag)