forked from TrueCloudLab/frostfs-s3-gw
Merge pull request #126 from KirillovDenis/feature/94-time_based_conditional
[#94] CopyObject/GetObject support conditional headers
This commit is contained in:
commit
daed0978a6
4 changed files with 117 additions and 42 deletions
|
@ -69,6 +69,7 @@ type (
|
|||
DstBucket string
|
||||
SrcObject string
|
||||
DstObject string
|
||||
SrcSize int64
|
||||
Header map[string]string
|
||||
}
|
||||
// CreateBucketParams stores bucket create request parameters.
|
||||
|
@ -398,11 +399,6 @@ func (n *layer) PutObject(ctx context.Context, p *PutObjectParams) (*ObjectInfo,
|
|||
|
||||
// CopyObject from one bucket into another bucket.
|
||||
func (n *layer) CopyObject(ctx context.Context, p *CopyObjectParams) (*ObjectInfo, error) {
|
||||
info, err := n.GetObjectInfo(ctx, p.SrcBucket, p.SrcObject)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("couldn't get object info: %w", err)
|
||||
}
|
||||
|
||||
pr, pw := io.Pipe()
|
||||
|
||||
go func() {
|
||||
|
@ -417,17 +413,12 @@ func (n *layer) CopyObject(ctx context.Context, p *CopyObjectParams) (*ObjectInf
|
|||
}
|
||||
}()
|
||||
|
||||
// set custom headers
|
||||
for k, v := range p.Header {
|
||||
info.Headers[k] = v
|
||||
}
|
||||
|
||||
return n.PutObject(ctx, &PutObjectParams{
|
||||
Bucket: p.DstBucket,
|
||||
Object: p.DstObject,
|
||||
Size: info.Size,
|
||||
Size: p.SrcSize,
|
||||
Reader: pr,
|
||||
Header: info.Headers,
|
||||
Header: p.Header,
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue