From c206381023db366079aebf11cf36aa9635c2b1fe Mon Sep 17 00:00:00 2001 From: Chris Schinnerl Date: Mon, 11 Mar 2024 13:40:02 +0100 Subject: [PATCH] extend CompleteMultipartUpload with metadata --- backend.go | 2 +- gofakes3.go | 7 ++++++- uploader.go | 6 +++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/backend.go b/backend.go index b72f604..298c57e 100644 --- a/backend.go +++ b/backend.go @@ -321,7 +321,7 @@ type MultipartBackend interface { ListParts(ctx context.Context, bucket, object string, uploadID UploadID, marker int, limit int64) (*ListMultipartUploadPartsResult, error) AbortMultipartUpload(ctx context.Context, bucket, object string, id UploadID) error - CompleteMultipartUpload(ctx context.Context, bucket, object string, id UploadID, input *CompleteMultipartUploadRequest) (*CompleteMultipartUploadResult, error) + CompleteMultipartUpload(ctx context.Context, bucket, object string, id UploadID, meta map[string]string, input *CompleteMultipartUploadRequest) (*CompleteMultipartUploadResult, error) } type AuthenticatedBackend interface { diff --git a/gofakes3.go b/gofakes3.go index 98e4dc5..d0189b0 100644 --- a/gofakes3.go +++ b/gofakes3.go @@ -970,7 +970,12 @@ func (g *GoFakeS3) completeMultipartUpload(bucket, object string, uploadID Uploa return err } - res, err := g.uploader.CompleteMultipartUpload(r.Context(), bucket, object, uploadID, &in) + meta, err := metadataHeaders(r.Header, g.timeSource.Now(), g.metadataSizeLimit) + if err != nil { + return err + } + + res, err := g.uploader.CompleteMultipartUpload(r.Context(), bucket, object, uploadID, meta, &in) if err != nil { return err } diff --git a/uploader.go b/uploader.go index c4f4718..6536b5f 100644 --- a/uploader.go +++ b/uploader.go @@ -404,12 +404,16 @@ func (u *uploader) UploadPart(_ context.Context, bucket, object string, id Uploa return &UploadPartResult{ETag: etag}, nil } -func (u *uploader) CompleteMultipartUpload(ctx context.Context, bucket, object string, id UploadID, input *CompleteMultipartUploadRequest) (*CompleteMultipartUploadResult, error) { +func (u *uploader) CompleteMultipartUpload(ctx context.Context, bucket, object string, id UploadID, meta map[string]string, input *CompleteMultipartUploadRequest) (*CompleteMultipartUploadResult, error) { mpu, err := u.getUnlocked(bucket, object, id) if err != nil { return nil, err } + for k, v := range meta { + mpu.Meta[k] = v + } + mpu.mu.Lock() defer mpu.mu.Unlock()