From 1a64fd95e191e87b9d0c1e0e9556cff92fc230a5 Mon Sep 17 00:00:00 2001 From: Stefan Majewsky Date: Wed, 2 May 2018 22:46:10 +0200 Subject: add (currently empty) CopyOptions arg to Object.CopyTo For backwards compatiblity when later expanding the scope of this function (analogous to DeleteOptions, UploadOptions, TruncateOptions). --- object.go | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'object.go') diff --git a/object.go b/object.go index a7b19df..d44c152 100644 --- a/object.go +++ b/object.go @@ -425,6 +425,12 @@ func (o *Object) Download(opts *RequestOptions) DownloadedObject { return DownloadedObject{body, err} } +//CopyOptions invokes advanced behavior in the Object.Copy() method. +// +//It's empty right now, but has been added providently to make future expansion +//backwards-compatible. +type CopyOptions struct{} + //CopyTo copies the object on the server side using a COPY request. To copy //only the content, not the metadata, use the X-Fresh-Metadata header: // @@ -438,18 +444,18 @@ func (o *Object) Download(opts *RequestOptions) DownloadedObject { // //A successful COPY implies target.Invalidate() since it may change the //target's metadata. -func (o *Object) CopyTo(target *Object, opts *RequestOptions) error { - opts = cloneRequestOptions(opts, nil) - opts.Headers.Set("Destination", target.FullName()) +func (o *Object) CopyTo(target *Object, opts *CopyOptions, ropts *RequestOptions) error { + ropts = cloneRequestOptions(ropts, nil) + ropts.Headers.Set("Destination", target.FullName()) if o.c.a.name != target.c.a.name { - opts.Headers.Set("Destination-Account", target.c.a.name) + ropts.Headers.Set("Destination-Account", target.c.a.name) } _, err := Request{ Method: "COPY", ContainerName: o.c.name, ObjectName: o.name, - Options: opts, + Options: ropts, ExpectStatusCodes: []int{201}, DrainResponseBody: true, }.Do(o.c.a.backend) -- cgit v1.2.3