|
@ -24,6 +24,9 @@ type InitiateMultipartUploadResult struct { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func (s3a *S3ApiServer) createMultipartUpload(input *s3.CreateMultipartUploadInput) (output *InitiateMultipartUploadResult, code s3err.ErrorCode) { |
|
|
func (s3a *S3ApiServer) createMultipartUpload(input *s3.CreateMultipartUploadInput) (output *InitiateMultipartUploadResult, code s3err.ErrorCode) { |
|
|
|
|
|
|
|
|
|
|
|
glog.V(2).Infof("createMultipartUpload input %v", input) |
|
|
|
|
|
|
|
|
uploadId, _ := uuid.NewRandom() |
|
|
uploadId, _ := uuid.NewRandom() |
|
|
uploadIdString := uploadId.String() |
|
|
uploadIdString := uploadId.String() |
|
|
|
|
|
|
|
@ -55,6 +58,8 @@ type CompleteMultipartUploadResult struct { |
|
|
|
|
|
|
|
|
func (s3a *S3ApiServer) completeMultipartUpload(input *s3.CompleteMultipartUploadInput) (output *CompleteMultipartUploadResult, code s3err.ErrorCode) { |
|
|
func (s3a *S3ApiServer) completeMultipartUpload(input *s3.CompleteMultipartUploadInput) (output *CompleteMultipartUploadResult, code s3err.ErrorCode) { |
|
|
|
|
|
|
|
|
|
|
|
glog.V(2).Infof("completeMultipartUpload input %v", input) |
|
|
|
|
|
|
|
|
uploadDirectory := s3a.genUploadsFolder(*input.Bucket) + "/" + *input.UploadId |
|
|
uploadDirectory := s3a.genUploadsFolder(*input.Bucket) + "/" + *input.UploadId |
|
|
|
|
|
|
|
|
entries, _, err := s3a.list(uploadDirectory, "", "", false, 0) |
|
|
entries, _, err := s3a.list(uploadDirectory, "", "", false, 0) |
|
@ -123,6 +128,8 @@ func (s3a *S3ApiServer) completeMultipartUpload(input *s3.CompleteMultipartUploa |
|
|
|
|
|
|
|
|
func (s3a *S3ApiServer) abortMultipartUpload(input *s3.AbortMultipartUploadInput) (output *s3.AbortMultipartUploadOutput, code s3err.ErrorCode) { |
|
|
func (s3a *S3ApiServer) abortMultipartUpload(input *s3.AbortMultipartUploadInput) (output *s3.AbortMultipartUploadOutput, code s3err.ErrorCode) { |
|
|
|
|
|
|
|
|
|
|
|
glog.V(2).Infof("abortMultipartUpload input %v", input) |
|
|
|
|
|
|
|
|
exists, err := s3a.exists(s3a.genUploadsFolder(*input.Bucket), *input.UploadId, true) |
|
|
exists, err := s3a.exists(s3a.genUploadsFolder(*input.Bucket), *input.UploadId, true) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
glog.V(1).Infof("bucket %s abort upload %s: %v", *input.Bucket, *input.UploadId, err) |
|
|
glog.V(1).Infof("bucket %s abort upload %s: %v", *input.Bucket, *input.UploadId, err) |
|
@ -159,6 +166,8 @@ type ListMultipartUploadsResult struct { |
|
|
func (s3a *S3ApiServer) listMultipartUploads(input *s3.ListMultipartUploadsInput) (output *ListMultipartUploadsResult, code s3err.ErrorCode) { |
|
|
func (s3a *S3ApiServer) listMultipartUploads(input *s3.ListMultipartUploadsInput) (output *ListMultipartUploadsResult, code s3err.ErrorCode) { |
|
|
// https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListMultipartUploads.html
|
|
|
// https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListMultipartUploads.html
|
|
|
|
|
|
|
|
|
|
|
|
glog.V(2).Infof("listMultipartUploads input %v", input) |
|
|
|
|
|
|
|
|
output = &ListMultipartUploadsResult{ |
|
|
output = &ListMultipartUploadsResult{ |
|
|
Bucket: input.Bucket, |
|
|
Bucket: input.Bucket, |
|
|
Delimiter: input.Delimiter, |
|
|
Delimiter: input.Delimiter, |
|
@ -168,7 +177,7 @@ func (s3a *S3ApiServer) listMultipartUploads(input *s3.ListMultipartUploadsInput |
|
|
Prefix: input.Prefix, |
|
|
Prefix: input.Prefix, |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
entries, isLast, err := s3a.list(s3a.genUploadsFolder(*input.Bucket), *input.Prefix, *input.KeyMarker, true, uint32(*input.MaxUploads)) |
|
|
|
|
|
|
|
|
entries, isLast, err := s3a.list(s3a.genUploadsFolder(*input.Bucket), "", *input.UploadIdMarker, false, uint32(*input.MaxUploads)) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
glog.Errorf("listMultipartUploads %s error: %v", *input.Bucket, err) |
|
|
glog.Errorf("listMultipartUploads %s error: %v", *input.Bucket, err) |
|
|
return |
|
|
return |
|
@ -177,9 +186,15 @@ func (s3a *S3ApiServer) listMultipartUploads(input *s3.ListMultipartUploadsInput |
|
|
|
|
|
|
|
|
for _, entry := range entries { |
|
|
for _, entry := range entries { |
|
|
if entry.Extended != nil { |
|
|
if entry.Extended != nil { |
|
|
key := entry.Extended["key"] |
|
|
|
|
|
|
|
|
key := string(entry.Extended["key"]) |
|
|
|
|
|
if *input.KeyMarker != "" && *input.KeyMarker != key { |
|
|
|
|
|
continue |
|
|
|
|
|
} |
|
|
|
|
|
if *input.Prefix != "" && !strings.HasPrefix(key, *input.Prefix) { |
|
|
|
|
|
continue |
|
|
|
|
|
} |
|
|
output.Upload = append(output.Upload, &s3.MultipartUpload{ |
|
|
output.Upload = append(output.Upload, &s3.MultipartUpload{ |
|
|
Key: objectKey(aws.String(string(key))), |
|
|
|
|
|
|
|
|
Key: objectKey(aws.String(key)), |
|
|
UploadId: aws.String(entry.Name), |
|
|
UploadId: aws.String(entry.Name), |
|
|
}) |
|
|
}) |
|
|
if !isLast { |
|
|
if !isLast { |
|
@ -209,6 +224,8 @@ type ListPartsResult struct { |
|
|
func (s3a *S3ApiServer) listObjectParts(input *s3.ListPartsInput) (output *ListPartsResult, code s3err.ErrorCode) { |
|
|
func (s3a *S3ApiServer) listObjectParts(input *s3.ListPartsInput) (output *ListPartsResult, code s3err.ErrorCode) { |
|
|
// https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListParts.html
|
|
|
// https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListParts.html
|
|
|
|
|
|
|
|
|
|
|
|
glog.V(2).Infof("listObjectParts input %v", input) |
|
|
|
|
|
|
|
|
output = &ListPartsResult{ |
|
|
output = &ListPartsResult{ |
|
|
Bucket: input.Bucket, |
|
|
Bucket: input.Bucket, |
|
|
Key: objectKey(input.Key), |
|
|
Key: objectKey(input.Key), |
|
|