|
@ -30,6 +30,13 @@ const ( |
|
|
func (s3a *S3ApiServer) NewMultipartUploadHandler(w http.ResponseWriter, r *http.Request) { |
|
|
func (s3a *S3ApiServer) NewMultipartUploadHandler(w http.ResponseWriter, r *http.Request) { |
|
|
bucket, object := s3_constants.GetBucketAndObject(r) |
|
|
bucket, object := s3_constants.GetBucketAndObject(r) |
|
|
|
|
|
|
|
|
|
|
|
//acl
|
|
|
|
|
|
errCode := s3a.CheckAccessForNewMultipartUpload(r, bucket, object) |
|
|
|
|
|
if errCode != s3err.ErrNone { |
|
|
|
|
|
s3err.WriteErrorResponse(w, r, errCode) |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
createMultipartUploadInput := &s3.CreateMultipartUploadInput{ |
|
|
createMultipartUploadInput := &s3.CreateMultipartUploadInput{ |
|
|
Bucket: aws.String(bucket), |
|
|
Bucket: aws.String(bucket), |
|
|
Key: objectKey(aws.String(object)), |
|
|
Key: objectKey(aws.String(object)), |
|
@ -230,31 +237,22 @@ func (s3a *S3ApiServer) PutObjectPartHandler(w http.ResponseWriter, r *http.Requ |
|
|
if s3a.iam.isEnabled() { |
|
|
if s3a.iam.isEnabled() { |
|
|
rAuthType := getRequestAuthType(r) |
|
|
rAuthType := getRequestAuthType(r) |
|
|
var s3ErrCode s3err.ErrorCode |
|
|
var s3ErrCode s3err.ErrorCode |
|
|
var identity *Identity |
|
|
|
|
|
switch rAuthType { |
|
|
switch rAuthType { |
|
|
case authTypeStreamingSigned: |
|
|
case authTypeStreamingSigned: |
|
|
dataReader, identity, s3ErrCode = s3a.iam.newSignV4ChunkedReader(r) |
|
|
|
|
|
|
|
|
dataReader, _, s3ErrCode = s3a.iam.newSignV4ChunkedReader(r) |
|
|
case authTypeSignedV2, authTypePresignedV2: |
|
|
case authTypeSignedV2, authTypePresignedV2: |
|
|
identity, s3ErrCode = s3a.iam.isReqAuthenticatedV2(r) |
|
|
|
|
|
|
|
|
_, s3ErrCode = s3a.iam.isReqAuthenticatedV2(r) |
|
|
case authTypePresigned, authTypeSigned: |
|
|
case authTypePresigned, authTypeSigned: |
|
|
identity, s3ErrCode = s3a.iam.reqSignatureV4Verify(r) |
|
|
|
|
|
|
|
|
_, s3ErrCode = s3a.iam.reqSignatureV4Verify(r) |
|
|
} |
|
|
} |
|
|
if s3ErrCode != s3err.ErrNone { |
|
|
if s3ErrCode != s3err.ErrNone { |
|
|
s3err.WriteErrorResponse(w, r, s3ErrCode) |
|
|
s3err.WriteErrorResponse(w, r, s3ErrCode) |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
r.Header.Set(s3_constants.AmzAccountId, identity.AccountId) |
|
|
|
|
|
} |
|
|
} |
|
|
defer dataReader.Close() |
|
|
defer dataReader.Close() |
|
|
|
|
|
|
|
|
glog.V(2).Infof("PutObjectPartHandler %s %s %04d", bucket, uploadID, partID) |
|
|
glog.V(2).Infof("PutObjectPartHandler %s %s %04d", bucket, uploadID, partID) |
|
|
|
|
|
|
|
|
s3ErrCode := s3a.checkAccessForWriteObject(r, bucket, object) |
|
|
|
|
|
if s3ErrCode != s3err.ErrNone { |
|
|
|
|
|
s3err.WriteErrorResponse(w, r, s3ErrCode) |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
uploadUrl := fmt.Sprintf("http://%s%s/%s/%04d.part", |
|
|
uploadUrl := fmt.Sprintf("http://%s%s/%s/%04d.part", |
|
|
s3a.option.Filer.ToHttpAddress(), s3a.genUploadsFolder(bucket), uploadID, partID) |
|
|
s3a.option.Filer.ToHttpAddress(), s3a.genUploadsFolder(bucket), uploadID, partID) |
|
|
|
|
|
|
|
|