You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
2.1 KiB

  1. package s3api
  2. import (
  3. "github.com/aws/aws-sdk-go/service/s3"
  4. "github.com/aws/aws-sdk-go/aws"
  5. "github.com/satori/go.uuid"
  6. "github.com/chrislusf/seaweedfs/weed/glog"
  7. "github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
  8. )
  9. func (s3a *S3ApiServer) createMultipartUpload(input *s3.CreateMultipartUploadInput) (output *s3.CreateMultipartUploadOutput, code ErrorCode) {
  10. uploadId, _ := uuid.NewV4()
  11. uploadIdString := uploadId.String()
  12. if err := s3a.mkdir(s3a.genUploadsFolder(*input.Bucket), uploadIdString, func(entry *filer_pb.Entry) {
  13. if entry.Extended == nil {
  14. entry.Extended = make(map[string][]byte)
  15. }
  16. entry.Extended["key"] = []byte(*input.Key)
  17. }); err != nil {
  18. glog.Errorf("NewMultipartUpload error: %v", err)
  19. return nil, ErrInternalError
  20. }
  21. output = &s3.CreateMultipartUploadOutput{
  22. Bucket: input.Bucket,
  23. Key: input.Key,
  24. UploadId: aws.String(uploadIdString),
  25. }
  26. return
  27. }
  28. func (s3a *S3ApiServer) completeMultipartUpload(input *s3.CompleteMultipartUploadInput) (output *s3.CompleteMultipartUploadOutput, code ErrorCode) {
  29. return
  30. }
  31. func (s3a *S3ApiServer) abortMultipartUpload(input *s3.AbortMultipartUploadInput) (output *s3.AbortMultipartUploadOutput, code ErrorCode) {
  32. return
  33. }
  34. func (s3a *S3ApiServer) listMultipartUploads(input *s3.ListMultipartUploadsInput) (output *s3.ListMultipartUploadsOutput, code ErrorCode) {
  35. entries, err := s3a.list(s3a.genUploadsFolder(*input.Bucket))
  36. if err != nil {
  37. glog.Errorf("listMultipartUploads %s error: %v", *input.Bucket, err)
  38. return nil, ErrNoSuchUpload
  39. }
  40. output = &s3.ListMultipartUploadsOutput{
  41. Bucket: input.Bucket,
  42. Delimiter: input.Delimiter,
  43. EncodingType: input.EncodingType,
  44. KeyMarker: input.KeyMarker,
  45. MaxUploads: input.MaxUploads,
  46. Prefix: input.Prefix,
  47. }
  48. for _, entry := range entries {
  49. if entry.Extended != nil {
  50. key := entry.Extended["key"]
  51. output.Uploads = append(output.Uploads, &s3.MultipartUpload{
  52. Key: aws.String(string(key)),
  53. UploadId: aws.String(entry.Name),
  54. })
  55. }
  56. }
  57. return
  58. }
  59. func (s3a *S3ApiServer) listObjectParts(input *s3.ListPartsInput) (output *s3.ListPartsOutput, code ErrorCode) {
  60. return
  61. }