Browse Source

S3: add metadata with multipart upload

fix https://github.com/chrislusf/seaweedfs/issues/2173
pull/2174/head
Chris Lu 4 years ago
parent
commit
c6d4c16079
  1. 3
      weed/s3api/filer_multipart.go
  2. 17
      weed/s3api/s3api_object_multipart_handlers.go
  3. 4
      weed/server/filer_server_handlers_write_autochunk.go

3
weed/s3api/filer_multipart.go

@ -35,6 +35,9 @@ func (s3a *S3ApiServer) createMultipartUpload(input *s3.CreateMultipartUploadInp
entry.Extended = make(map[string][]byte)
}
entry.Extended["key"] = []byte(*input.Key)
for k, v := range input.Metadata {
entry.Extended[k] = []byte(*v)
}
}); err != nil {
glog.Errorf("NewMultipartUpload error: %v", err)
return nil, s3err.ErrInternalError

17
weed/s3api/s3api_object_multipart_handlers.go

@ -4,6 +4,7 @@ import (
"fmt"
"github.com/chrislusf/seaweedfs/weed/glog"
"github.com/chrislusf/seaweedfs/weed/s3api/s3err"
weed_server "github.com/chrislusf/seaweedfs/weed/server"
"net/http"
"net/url"
"strconv"
@ -24,10 +25,18 @@ const (
func (s3a *S3ApiServer) NewMultipartUploadHandler(w http.ResponseWriter, r *http.Request) {
bucket, object := getBucketAndObject(r)
response, errCode := s3a.createMultipartUpload(&s3.CreateMultipartUploadInput{
Bucket: aws.String(bucket),
Key: objectKey(aws.String(object)),
})
createMultipartUploadInput := &s3.CreateMultipartUploadInput{
Bucket: aws.String(bucket),
Key: objectKey(aws.String(object)),
Metadata: make(map[string]*string),
}
metadata := weed_server.SaveAmzMetaData(r, nil, false)
for k, v := range metadata {
createMultipartUploadInput.Metadata[k] = aws.String(string(v))
}
response, errCode := s3a.createMultipartUpload(createMultipartUploadInput)
glog.V(2).Info("NewMultipartUploadHandler", s3err.EncodeXMLResponse(response), errCode)

4
weed/server/filer_server_handlers_write_autochunk.go

@ -214,10 +214,6 @@ func (fs *FilerServer) saveMetaData(ctx context.Context, r *http.Request, fileNa
Size: int64(entry.FileSize),
}
if entry.Extended == nil {
entry.Extended = make(map[string][]byte)
}
entry.Extended = SaveAmzMetaData(r, entry.Extended, false)
for k, v := range r.Header {

Loading…
Cancel
Save