Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions blob/blob.go
Original file line number Diff line number Diff line change
Expand Up @@ -1216,6 +1216,7 @@ func (b *Bucket) Copy(ctx context.Context, dstKey, srcKey string, opts *CopyOpti
}
dopts := &driver.CopyOptions{
BeforeCopy: opts.BeforeCopy,
Tags: opts.Tags,
}
b.mu.RLock()
defer b.mu.RUnlock()
Expand Down Expand Up @@ -1459,6 +1460,10 @@ type CopyOptions struct {
// asFunc converts its argument to driver-specific types.
// See https://gocloud.dev/concepts/as/ for background information.
BeforeCopy func(asFunc func(any) bool) error

// Tags holds key/value tags to be associated with the blob, or nil.
// Keys and values must be not empty if specified.
Tags map[string]string
}

// BucketURLOpener represents types that can open buckets based on a URL.
Expand Down
4 changes: 4 additions & 0 deletions blob/driver/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ type CopyOptions struct {
// asFunc allows drivers to expose driver-specific types;
// see Bucket.As for more details.
BeforeCopy func(asFunc func(any) bool) error

// Tags holds key/value tags to be associated with the blob, or nil.
// Keys and values must be not empty if specified.
Tags map[string]string
}

// ReaderAttributes contains a subset of attributes about a blob that are
Expand Down
5 changes: 5 additions & 0 deletions blob/s3blob/s3blob.go
Original file line number Diff line number Diff line change
Expand Up @@ -853,6 +853,11 @@ func (b *bucket) Copy(ctx context.Context, dstKey, srcKey string, opts *driver.C
if b.kmsKeyId != "" {
input.SSEKMSKeyId = aws.String(b.kmsKeyId)
}
if len(opts.Tags) > 0 {
encodedTags := encodeTags(opts.Tags)
input.Tagging = aws.String(encodedTags)
}

if opts.BeforeCopy != nil {
asFunc := func(i any) bool {
switch v := i.(type) {
Expand Down
Loading