ruby/example_code/s3/s3-ruby-example-access-permissions.rb
def object_uploaded?(s3_client, bucket_name, object_key, object_content)
  s3_client.put_object(
    bucket: bucket_name,
    key: object_key,
    body: object_content
  )
  return true
rescue StandardError => e
  puts "Error uploading object: #{e.message}"
  return false
end
# Uploads an object 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 bucket's name.
# @param object_key [String] The name of the object.
# @param object_content [String] The content to add to the object.
# @return [Boolean] true if the object was uploaded; otherwise, false.
# @example
#   exit 1 unless object_uploaded?(
#     Aws::S3::Client.new(region: 'us-west-2'),
#     'doc-example-bucket',
#     'my-file.txt',
#     'This is the content of my-file.txt.'
#   )

Uploads an object to an Amazon S3 bucket.
Prerequisites.

An Amazon S3 bucket.
Uploads an object to an Amazon S3 bucket . Prerequisites . An Amazon S3 bucket .
def object_uploaded?(s3_client, bucket_name, object_key, object_content)
  s3_client.put_object(
    bucket: bucket_name,
    key: object_key,
    body: object_content
  )
  return true
rescue StandardError => e
  puts "Error uploading object: #{e.message}"
  return false
end
def object_uploaded? ( s3_client , bucket_name , object_key , object_content ) s3_client . put_object ( bucket : bucket_name , key : object_key , body : object_content ) return true rescue StandardError => e puts "Error uploading object: #{e.message}" return false end
Uploads an object to an Amazon S3 bucket.
Uploads an object 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 bucket's name.
The bucket ' s name .
object_key
The name of the object.
The name of the object .
object_content
The content to add to the object.
The content to add to the object .
example
exit 1 unless object_uploaded?( Aws::S3::Client.new(region: 'us-west-2'), 'doc-example-bucket', 'my-file.txt', 'This is the content of my-file.txt.' )
exit 1 unless object_uploaded? ( Aws :: S3 :: Client . new ( region : ' us - west - 2 ' ) ' doc - example - bucket ' ' my - file . txt ' ' This is the content of my - file . txt . ' )