From 954ad98e0d0f2276f69afe2e5176e66c87aeb0ba Mon Sep 17 00:00:00 2001 From: elee Date: Sun, 27 Feb 2022 04:49:31 -0600 Subject: [PATCH 1/2] set canned acl on replication create --- weed/replication/sink/s3sink/s3_sink.go | 6 +++++- weed/replication/sink/s3sink/s3_write.go | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/weed/replication/sink/s3sink/s3_sink.go b/weed/replication/sink/s3sink/s3_sink.go index c3da1ee3f..a118324c2 100644 --- a/weed/replication/sink/s3sink/s3_sink.go +++ b/weed/replication/sink/s3sink/s3_sink.go @@ -26,6 +26,7 @@ type S3Sink struct { bucket string dir string endpoint string + acl string filerSource *source.FilerSource isIncremental bool } @@ -51,6 +52,7 @@ func (s3sink *S3Sink) Initialize(configuration util.Configuration, prefix string glog.V(0).Infof("sink.s3.bucket: %v", configuration.GetString(prefix+"bucket")) glog.V(0).Infof("sink.s3.directory: %v", configuration.GetString(prefix+"directory")) glog.V(0).Infof("sink.s3.endpoint: %v", configuration.GetString(prefix+"endpoint")) + glog.V(0).Infof("sink.s3.acl: %v", configuration.GetString(prefix+"acl")) glog.V(0).Infof("sink.s3.is_incremental: %v", configuration.GetString(prefix+"is_incremental")) s3sink.isIncremental = configuration.GetBool(prefix + "is_incremental") return s3sink.initialize( @@ -60,6 +62,7 @@ func (s3sink *S3Sink) Initialize(configuration util.Configuration, prefix string configuration.GetString(prefix+"bucket"), configuration.GetString(prefix+"directory"), configuration.GetString(prefix+"endpoint"), + configuration.GetString(prefix+"acl"), ) } @@ -67,11 +70,12 @@ func (s3sink *S3Sink) SetSourceFiler(s *source.FilerSource) { s3sink.filerSource = s } -func (s3sink *S3Sink) initialize(awsAccessKeyId, awsSecretAccessKey, region, bucket, dir, endpoint string) error { +func (s3sink *S3Sink) initialize(awsAccessKeyId, awsSecretAccessKey, region, bucket, dir, endpoint, acl string) error { s3sink.region = region s3sink.bucket = bucket s3sink.dir = dir s3sink.endpoint = endpoint + s3sink.acl = acl config := &aws.Config{ Region: aws.String(s3sink.region), diff --git a/weed/replication/sink/s3sink/s3_write.go b/weed/replication/sink/s3sink/s3_write.go index 3dde52616..07eb65271 100644 --- a/weed/replication/sink/s3sink/s3_write.go +++ b/weed/replication/sink/s3sink/s3_write.go @@ -38,6 +38,7 @@ func (s3sink *S3Sink) createMultipartUpload(key string, entry *filer_pb.Entry) ( Bucket: aws.String(s3sink.bucket), Key: aws.String(key), ContentType: aws.String(entry.Attributes.Mime), + ACL: aws.String(s3sink.acl), } result, err := s3sink.conn.CreateMultipartUpload(input) From 881a0fe8068cc197378967527663500161f2ff20 Mon Sep 17 00:00:00 2001 From: elee Date: Sun, 27 Feb 2022 04:50:59 -0600 Subject: [PATCH 2/2] ensure compatibility --- weed/replication/sink/s3sink/s3_write.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/weed/replication/sink/s3sink/s3_write.go b/weed/replication/sink/s3sink/s3_write.go index 07eb65271..7d8932fb0 100644 --- a/weed/replication/sink/s3sink/s3_write.go +++ b/weed/replication/sink/s3sink/s3_write.go @@ -38,7 +38,9 @@ func (s3sink *S3Sink) createMultipartUpload(key string, entry *filer_pb.Entry) ( Bucket: aws.String(s3sink.bucket), Key: aws.String(key), ContentType: aws.String(entry.Attributes.Mime), - ACL: aws.String(s3sink.acl), + } + if s3sink.acl != "" { + input.ACL = aws.String(s3sink.acl) } result, err := s3sink.conn.CreateMultipartUpload(input)