這次用 go aws SDK 做 server side encryption 沒有想到 SDK 搞人...
key 跟 key md5 居然一個不用 encode 一個卻要, 害我測試半天...
正確範例如下:
SSECustomerAlgorithm := "AES256"
// 32 bytes key
SSECustomerKey := "32byteslongsecretkeymustprovided"
// key md5 -> ECFA4F2C02B6E8E36555418E5A5BAC7E
// key md5 base64 -> 7PpPLAK26ONlVUGOWlusfg==
// create key md5 base64 command
// echo -n key | openssl dgst -binary -md5 | base64
SSECustomerKeyMD5 := "7PpPLAK26ONlVUGOWlusfg=="
S3Service.CreateMultipartUploadWithContext(ctx, &s3.CreateMultipartUploadInput{
Key: aws.String(Key),
Bucket: aws.String(BucketName),
ContentType: aws.String(mimeType),
SSECustomerAlgorithm: aws.String(SSECustomerAlgorithm),
SSECustomerKey: aws.String(SSECustomerKey),
SSECustomerKeyMD5: aws.String(SSECustomerKeyMD5),
})
ps. SSECustomerKeyMD5 可以不帶, SDK 會幫忙算
留言列表