mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
feat:add a uuid after uploadid (#3963)
This commit is contained in:
parent
180853a2c9
commit
df0662038c
|
@ -4,6 +4,7 @@ import (
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"encoding/xml"
|
"encoding/xml"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/google/uuid"
|
||||||
"github.com/seaweedfs/seaweedfs/weed/s3api/s3err"
|
"github.com/seaweedfs/seaweedfs/weed/s3api/s3err"
|
||||||
"golang.org/x/exp/slices"
|
"golang.org/x/exp/slices"
|
||||||
"math"
|
"math"
|
||||||
|
@ -32,6 +33,8 @@ func (s3a *S3ApiServer) createMultipartUpload(input *s3.CreateMultipartUploadInp
|
||||||
|
|
||||||
uploadIdString := s3a.generateUploadID(*input.Key)
|
uploadIdString := s3a.generateUploadID(*input.Key)
|
||||||
|
|
||||||
|
uploadIdString = uploadIdString + "_" +strings.ReplaceAll(uuid.New().String(),"-","")
|
||||||
|
|
||||||
if err := s3a.mkdir(s3a.genUploadsFolder(*input.Bucket), uploadIdString, func(entry *filer_pb.Entry) {
|
if err := s3a.mkdir(s3a.genUploadsFolder(*input.Bucket), uploadIdString, func(entry *filer_pb.Entry) {
|
||||||
if entry.Extended == nil {
|
if entry.Extended == nil {
|
||||||
entry.Extended = make(map[string][]byte)
|
entry.Extended = make(map[string][]byte)
|
||||||
|
|
|
@ -284,8 +284,9 @@ func (s3a *S3ApiServer) generateUploadID(object string) string {
|
||||||
// Check object name and uploadID when processing multipart uploading
|
// Check object name and uploadID when processing multipart uploading
|
||||||
func (s3a *S3ApiServer) checkUploadId(object string, id string) error {
|
func (s3a *S3ApiServer) checkUploadId(object string, id string) error {
|
||||||
|
|
||||||
hash := s3a.generateUploadID(object)
|
hash := s3a.generateUploadID(strings.Split(object, "_")[0])
|
||||||
if hash != id {
|
|
||||||
|
if !strings.HasPrefix(id, hash) {
|
||||||
glog.Errorf("object %s and uploadID %s are not matched", object, id)
|
glog.Errorf("object %s and uploadID %s are not matched", object, id)
|
||||||
return fmt.Errorf("object %s and uploadID %s are not matched", object, id)
|
return fmt.Errorf("object %s and uploadID %s are not matched", object, id)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue