ruby/example_code/s3/s3_add_cspk_encrypt_item.rb
# Uploads an object with encrypted content to an Amazon S3 bucket.
#
# Prerequisites:
#
# - An Amazon S3 bucket.
#
# @param s3_client [Aws::S3::Client] An initialized Amazon S3 client.
# @param bucket_name [String] The name of the bucket.
# @param object_key [String] The name of the object to upload.
# @param encrypted_object_content [String] The encrypted content of
#   the object to upload.
# @return [Boolean] true if the object was uploaded; otherwise, false.
# @example
#   s3_client = Aws::S3::Client.new(region: 'us-west-2')
#   if encrypted_object_uploaded?(
#     s3_client,
#     'doc-example-bucket',
#     'my-file.txt',
#     'This is the content of my-file.txt.'
#   )
#     puts 'Uploaded.'
#   else
#     puts 'Not uploaded.'
#   end

Uploads an object with encrypted content to an Amazon S3 bucket.
Prerequisites.

An Amazon S3 bucket.
Uploads an object with encrypted content to an Amazon S3 bucket . Prerequisites . An Amazon S3 bucket .
def encrypted_object_uploaded?(
  s3_client,
  bucket_name,
  object_key,
  encrypted_object_content
)
  s3_client.put_object(
    bucket: bucket_name,
    key: object_key,
    body: encrypted_object_content
  )
  return true
rescue StandardError => e
  puts "Error uploading object: #{e.message}"
  return false
end
def encrypted_object_uploaded? ( s3_client , bucket_name , object_key , encrypted_object_content ) s3_client . put_object ( bucket : bucket_name , key : object_key , body : encrypted_object_content ) return true rescue StandardError => e puts "Error uploading object: #{e.message}" return false end
Uploads an object with encrypted content to an Amazon S3 bucket.
Uploads an object with encrypted content to an Amazon S3 bucket .
true if the object was uploaded; otherwise, false.
true if the object was uploaded ; otherwise false .
Boolean
s3_client
An initialized Amazon S3 client.
An initialized Amazon S3 client .
bucket_name
The name of the bucket.
The name of the bucket .
object_key
The name of the object to upload.
The name of the object to upload .
encrypted_object_content
The encrypted content of the object to upload.
The encrypted content of the object to upload .
example
s3_client = Aws::S3::Client.new(region: 'us-west-2') if encrypted_object_uploaded?( s3_client, 'doc-example-bucket', 'my-file.txt', 'This is the content of my-file.txt.' ) puts 'Uploaded.' else puts 'Not uploaded.' end
s3_client = Aws :: S3 :: Client . new ( region : ' us - west - 2 ' ) if encrypted_object_uploaded? ( s3_client ' doc - example - bucket ' ' my - file . txt ' ' This is the content of my - file . txt . ' ) puts ' Uploaded . ' else puts ' Not uploaded . ' end