From 459e10d599ffed2a1c97b74b702aab9d60bc66b4 Mon Sep 17 00:00:00 2001 From: Riaz Arbi Date: Thu, 30 Oct 2025 17:20:16 +0200 Subject: [PATCH] gcs: fix --gcs-storage-class to work with server side copy for objects --- backend/googlecloudstorage/googlecloudstorage.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/backend/googlecloudstorage/googlecloudstorage.go b/backend/googlecloudstorage/googlecloudstorage.go index 1994edd50..449e371bc 100644 --- a/backend/googlecloudstorage/googlecloudstorage.go +++ b/backend/googlecloudstorage/googlecloudstorage.go @@ -1134,7 +1134,15 @@ func (f *Fs) Copy(ctx context.Context, src fs.Object, remote string) (fs.Object, remote: remote, } - rewriteRequest := f.svc.Objects.Rewrite(srcBucket, srcPath, dstBucket, dstPath, nil) + // Set the storage class for the destination object if configured + var dstObject *storage.Object + if f.opt.StorageClass != "" { + dstObject = &storage.Object{ + StorageClass: f.opt.StorageClass, + } + } + + rewriteRequest := f.svc.Objects.Rewrite(srcBucket, srcPath, dstBucket, dstPath, dstObject) if !f.opt.BucketPolicyOnly { rewriteRequest.DestinationPredefinedAcl(f.opt.ObjectACL) } @@ -1422,6 +1430,10 @@ func (o *Object) Update(ctx context.Context, in io.Reader, src fs.ObjectInfo, op ContentType: fs.MimeType(ctx, src), Metadata: metadataFromModTime(modTime), } + // Set the storage class from config if configured + if o.fs.opt.StorageClass != "" { + object.StorageClass = o.fs.opt.StorageClass + } // Apply upload options for _, option := range options { key, value := option.Header()