diff --git a/api/handler/copy.go b/api/handler/copy.go index 6f65d0053..652abf271 100644 --- a/api/handler/copy.go +++ b/api/handler/copy.go @@ -102,6 +102,7 @@ func (h *handler) CopyObjectHandler(w http.ResponseWriter, r *http.Request) { params := &layer.CopyObjectParams{ SrcObject: info, + ScrBktInfo: p.BktInfo, DstBktInfo: dstBktInfo, DstObject: reqInfo.ObjectName, SrcSize: info.Size, diff --git a/api/handler/get.go b/api/handler/get.go index cd7080ecd..95804719f 100644 --- a/api/handler/get.go +++ b/api/handler/get.go @@ -164,6 +164,7 @@ func (h *handler) GetObjectHandler(w http.ResponseWriter, r *http.Request) { ObjectInfo: info, Writer: w, Range: params, + BucketInfo: bktInfo, } if err = h.obj.GetObject(r.Context(), getParams); err != nil { h.logAndSendError(w, "could not get object", reqInfo, err) diff --git a/api/handler/head.go b/api/handler/head.go index 67c4a525e..2e11696be 100644 --- a/api/handler/head.go +++ b/api/handler/head.go @@ -74,6 +74,7 @@ func (h *handler) HeadObjectHandler(w http.ResponseWriter, r *http.Request) { ObjectInfo: info, Writer: buffer, Range: getRangeToDetectContentType(info.Size), + BucketInfo: bktInfo, } if err = h.obj.GetObject(r.Context(), getParams); err != nil { h.logAndSendError(w, "could not get object", reqInfo, err, zap.Stringer("oid", info.ID)) diff --git a/api/handler/multipart_upload.go b/api/handler/multipart_upload.go index 0aad7a08b..222eda444 100644 --- a/api/handler/multipart_upload.go +++ b/api/handler/multipart_upload.go @@ -316,6 +316,7 @@ func (h *handler) UploadPartCopy(w http.ResponseWriter, r *http.Request) { Key: reqInfo.ObjectName, }, SrcObjInfo: srcInfo, + SrcBktInfo: srcBktInfo, PartNumber: partNumber, Range: srcRange, } @@ -380,6 +381,7 @@ func (h *handler) CompleteMultipartUploadHandler(w http.ResponseWriter, r *http. p := &layer.GetObjectParams{ ObjectInfo: initPart, Writer: initPartPayload, + BucketInfo: bktInfo, } if err = h.obj.GetObject(r.Context(), p); err != nil { h.logAndSendError(w, "could not get multipart upload acl and/or tagging", reqInfo, err, additional...) diff --git a/api/layer/layer.go b/api/layer/layer.go index e16e9f16c..41d7200fe 100644 --- a/api/layer/layer.go +++ b/api/layer/layer.go @@ -78,6 +78,7 @@ type ( GetObjectParams struct { Range *RangeParams ObjectInfo *data.ObjectInfo + BucketInfo *data.BucketInfo Writer io.Writer } @@ -125,6 +126,7 @@ type ( // CopyObjectParams stores object copy request parameters. CopyObjectParams struct { SrcObject *data.ObjectInfo + ScrBktInfo *data.BucketInfo DstBktInfo *data.BucketInfo DstObject string SrcSize int64 @@ -382,6 +384,7 @@ func (n *layer) GetObject(ctx context.Context, p *GetObjectParams) error { var params getParams params.objInfo = p.ObjectInfo + params.bktInfo = p.BucketInfo if p.Range != nil { if p.Range.Start > p.Range.End { @@ -517,6 +520,7 @@ func (n *layer) CopyObject(ctx context.Context, p *CopyObjectParams) (*data.Obje ObjectInfo: p.SrcObject, Writer: pw, Range: p.Range, + BucketInfo: p.ScrBktInfo, }) if err = pw.CloseWithError(err); err != nil { diff --git a/api/layer/multipart_upload.go b/api/layer/multipart_upload.go index 1eae6577d..ba7538c46 100644 --- a/api/layer/multipart_upload.go +++ b/api/layer/multipart_upload.go @@ -52,6 +52,7 @@ type ( UploadCopyParams struct { Info *UploadInfoParams SrcObjInfo *data.ObjectInfo + SrcBktInfo *data.BucketInfo PartNumber int Range *RangeParams } @@ -167,6 +168,7 @@ func (n *layer) UploadPartCopy(ctx context.Context, p *UploadCopyParams) (*data. ObjectInfo: p.SrcObjInfo, Writer: pw, Range: p.Range, + BucketInfo: p.SrcBktInfo, }) if err = pw.CloseWithError(err); err != nil { @@ -307,6 +309,8 @@ func (n *layer) CompleteMultipartUpload(ctx context.Context, p *CompleteMultipar parts: parts, } + r.prm.bktInfo = p.Info.Bkt + obj, err = n.PutObject(ctx, &PutObjectParams{ BktInfo: p.Info.Bkt, Object: p.Info.Key, diff --git a/api/layer/object.go b/api/layer/object.go index ab71784ca..7714d7bca 100644 --- a/api/layer/object.go +++ b/api/layer/object.go @@ -36,6 +36,7 @@ type ( off, ln uint64 objInfo *data.ObjectInfo + bktInfo *data.BucketInfo } // ListObjectsParamsCommon contains common parameters for ListObjectsV1 and ListObjectsV2. @@ -126,13 +127,7 @@ func (n *layer) initObjectPayloadReader(ctx context.Context, p getParams) (io.Re PayloadRange: [2]uint64{p.off, p.ln}, } - // should be taken from cache - bktInfo, err := n.GetBucketInfo(ctx, p.objInfo.Bucket) - if err != nil { - return nil, err - } - - n.prepareAuthParameters(ctx, &prm.PrmAuth, bktInfo.Owner) + n.prepareAuthParameters(ctx, &prm.PrmAuth, p.bktInfo.Owner) res, err := n.neoFS.ReadObject(ctx, prm) if err != nil {