Skip to content

Commit

Permalink
Bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
ddl-rliu committed Feb 15, 2024
1 parent 8104883 commit cc4eab8
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions s3/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,15 +202,25 @@ func (c *container) Put(name string, r io.Reader, size int64, metadata map[strin
Body: r,
Metadata: mdPrepped, // map[string]*string
}
if bucketEncrypted, sseAlgortihm, encryptionKey := getKmsMasterKeyId(c.client, c.name); bucketEncrypted {
switch sseAlgortihm {
case s3.ServerSideEncryptionAes256:
params.ServerSideEncryption = aws.String(sseAlgortihm)
case s3.ServerSideEncryptionAwsKms:
params.ServerSideEncryption = aws.String(sseAlgortihm)
if encryptionKey != "" {
params.SSEKMSKeyId = aws.String(encryptionKey)
}

// First, try to set SSE using stow.config
var extraArgs S3ExtraArgs
json.Unmarshal([]byte(c.extraArgs), &extraArgs)

if extraArgs.ServerSideEncryption == "" {
// As backup, try to set SSE using s3.GetBucketEncryption
if bucketEncrypted, sseAlgortihm, encryptionKey := getKmsMasterKeyId(c.client, c.name); bucketEncrypted {
extraArgs.ServerSideEncryption, extraArgs.SSEKMSKeyId = sseAlgortihm, encryptionKey
}
}

switch extraArgs.ServerSideEncryption {
case s3.ServerSideEncryptionAes256:
params.ServerSideEncryption = aws.String(extraArgs.ServerSideEncryption)
case s3.ServerSideEncryptionAwsKms:
params.ServerSideEncryption = aws.String(extraArgs.ServerSideEncryption)
if extraArgs.SSEKMSKeyId != "" {
params.SSEKMSKeyId = aws.String(extraArgs.SSEKMSKeyId)
}
}

Expand Down

0 comments on commit cc4eab8

Please sign in to comment.