mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
S3: add metadata with multipart upload
fix https://github.com/chrislusf/seaweedfs/issues/2173
This commit is contained in:
parent
2420c60fc4
commit
c6d4c16079
|
@ -35,6 +35,9 @@ func (s3a *S3ApiServer) createMultipartUpload(input *s3.CreateMultipartUploadInp
|
||||||
entry.Extended = make(map[string][]byte)
|
entry.Extended = make(map[string][]byte)
|
||||||
}
|
}
|
||||||
entry.Extended["key"] = []byte(*input.Key)
|
entry.Extended["key"] = []byte(*input.Key)
|
||||||
|
for k, v := range input.Metadata {
|
||||||
|
entry.Extended[k] = []byte(*v)
|
||||||
|
}
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
glog.Errorf("NewMultipartUpload error: %v", err)
|
glog.Errorf("NewMultipartUpload error: %v", err)
|
||||||
return nil, s3err.ErrInternalError
|
return nil, s3err.ErrInternalError
|
||||||
|
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/chrislusf/seaweedfs/weed/glog"
|
"github.com/chrislusf/seaweedfs/weed/glog"
|
||||||
"github.com/chrislusf/seaweedfs/weed/s3api/s3err"
|
"github.com/chrislusf/seaweedfs/weed/s3api/s3err"
|
||||||
|
weed_server "github.com/chrislusf/seaweedfs/weed/server"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
@ -24,10 +25,18 @@ const (
|
||||||
func (s3a *S3ApiServer) NewMultipartUploadHandler(w http.ResponseWriter, r *http.Request) {
|
func (s3a *S3ApiServer) NewMultipartUploadHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
bucket, object := getBucketAndObject(r)
|
bucket, object := getBucketAndObject(r)
|
||||||
|
|
||||||
response, errCode := s3a.createMultipartUpload(&s3.CreateMultipartUploadInput{
|
createMultipartUploadInput := &s3.CreateMultipartUploadInput{
|
||||||
Bucket: aws.String(bucket),
|
Bucket: aws.String(bucket),
|
||||||
Key: objectKey(aws.String(object)),
|
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)
|
glog.V(2).Info("NewMultipartUploadHandler", s3err.EncodeXMLResponse(response), errCode)
|
||||||
|
|
||||||
|
|
|
@ -214,10 +214,6 @@ func (fs *FilerServer) saveMetaData(ctx context.Context, r *http.Request, fileNa
|
||||||
Size: int64(entry.FileSize),
|
Size: int64(entry.FileSize),
|
||||||
}
|
}
|
||||||
|
|
||||||
if entry.Extended == nil {
|
|
||||||
entry.Extended = make(map[string][]byte)
|
|
||||||
}
|
|
||||||
|
|
||||||
entry.Extended = SaveAmzMetaData(r, entry.Extended, false)
|
entry.Extended = SaveAmzMetaData(r, entry.Extended, false)
|
||||||
|
|
||||||
for k, v := range r.Header {
|
for k, v := range r.Header {
|
||||||
|
|
Loading…
Reference in a new issue