AWS Code Sample


copy_object_encrypt_copy.rb demonstrates how to copy an object and encrypt the copy.

#** #* Copyright 2010-2019, Inc. or its affiliates. All Rights Reserved. #* #* This file is licensed under the Apache License, Version 2.0 (the "License"). #* You may not use this file except in compliance with the License. A copy of #* the License is located at #* #* #* #* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR #* CONDITIONS OF ANY KIND, either express or implied. See the License for the #* specific language governing permissions and limitations under the License. #** require 'aws-sdk-s3' regionName = 'us-west-2' encryptionType = 'AES256' s3 = bucket1 = s3.bucket('source-bucket-name') bucket2 = s3.bucket('target-bucket-name') obj1 = bucket1.object('Bucket1Key') obj2 = bucket2.object('Bucket2Key') obj1.copy_to(obj2, :server_side_encryption => encryptionType)

Sample Details

Service: s3

Last tested: 2019-01-28

Author: AWS

Type: full-example

On this page: