Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

gcs: fix --gcs-storage-class to work with server side copy for objects

Riaz Arbi459e10d599ff
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()