Class: Aws::S3::Client

Inherits:
Seahorse::Client::Base
  • Object
show all
Includes:
ClientStubs
Defined in:
lib/aws-sdk-s3/client.rb

Class Attribute Summary collapse

API Operations collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Client

Returns a new instance of Client.

Parameters:

  • options (Hash)

Options Hash (options):

  • :credentials (required, Aws::CredentialProvider)

    Your AWS credentials. This can be an instance of any one of the following classes:

    • ‘Aws::Credentials` - Used for configuring static, non-refreshing credentials.

    • ‘Aws::InstanceProfileCredentials` - Used for loading credentials from an EC2 IMDS on an EC2 instance.

    • ‘Aws::SharedCredentials` - Used for loading credentials from a shared file, such as `~/.aws/config`.

    • ‘Aws::AssumeRoleCredentials` - Used when you need to assume a role.

    When ‘:credentials` are not configured directly, the following locations will be searched for credentials:

    • Aws.config`

    • The ‘:access_key_id`, `:secret_access_key`, and `:session_token` options.

    • ENV, ENV

    • ‘~/.aws/credentials`

    • ‘~/.aws/config`

    • EC2 IMDS instance profile - When used by default, the timeouts are very aggressive. Construct and pass an instance of ‘Aws::InstanceProfileCredentails` to enable retries and extended timeouts.

  • :region (required, String)

    The AWS region to connect to. The configured ‘:region` is used to determine the service `:endpoint`. When not passed, a default `:region` is search for in the following locations:

  • :access_key_id (String)
  • :active_endpoint_cache (Boolean) — default: false

    When set to ‘true`, a thread polling for endpoints will be running in the background every 60 secs (default). Defaults to `false`.

  • :client_side_monitoring (Boolean) — default: false

    When ‘true`, client-side metrics will be collected for all API requests from this client.

  • :client_side_monitoring_client_id (String) — default: ""

    Allows you to provide an identifier for this client which will be attached to all generated client side metrics. Defaults to an empty string.

  • :client_side_monitoring_port (Integer) — default: 31000

    Required for publishing client metrics. The port that the client side monitoring agent is running on, where client metrics will be published via UDP.

  • :client_side_monitoring_publisher (Aws::ClientSideMonitoring::Publisher) — default: Aws::ClientSideMonitoring::Publisher

    Allows you to provide a custom client-side monitoring publisher class. By default, will use the Client Side Monitoring Agent Publisher.

  • :compute_checksums (Boolean) — default: true

    When ‘true` a MD5 checksum will be computed for every request that sends a body. When `false`, MD5 checksums will only be computed for operations that require them. Checksum errors returned by Amazon S3 are automatically retried up to `:retry_limit` times.

  • :convert_params (Boolean) — default: true

    When ‘true`, an attempt is made to coerce request parameters into the required types.

  • :disable_host_prefix_injection (Boolean) — default: false

    Set to true to disable SDK automatically adding host prefix to default service endpoint when available.

  • :endpoint (String)

    The client endpoint is normally constructed from the ‘:region` option. You should only configure an `:endpoint` when connecting to test endpoints. This should be avalid HTTP(S) URI.

  • :endpoint_cache_max_entries (Integer) — default: 1000

    Used for the maximum size limit of the LRU cache storing endpoints data for endpoint discovery enabled operations. Defaults to 1000.

  • :endpoint_cache_max_threads (Integer) — default: 10

    Used for the maximum threads in use for polling endpoints to be cached, defaults to 10.

  • :endpoint_cache_poll_interval (Integer) — default: 60

    When :endpoint_discovery and :active_endpoint_cache is enabled, Use this option to config the time interval in seconds for making requests fetching endpoints information. Defaults to 60 sec.

  • :endpoint_discovery (Boolean) — default: false

    When set to ‘true`, endpoint discovery will be enabled for operations when available. Defaults to `false`.

  • :event_stream_handler (Proc)

    When an EventStream or Proc object is provided, it will be used as callback for each chunk of event stream response received along the way.

  • :follow_redirects (Boolean) — default: true

    When ‘true`, this client will follow 307 redirects returned by Amazon S3.

  • :force_path_style (Boolean) — default: false

    When set to ‘true`, the bucket name is always left in the request URI and never moved to the host as a sub-domain.

  • :log_formatter (Aws::Log::Formatter) — default: Aws::Log::Formatter.default

    The log formatter.

  • :log_level (Symbol) — default: :info

    The log level to send messages to the ‘:logger` at.

  • :logger (Logger)

    The Logger instance to send log messages to. If this option is not set, logging will be disabled.

  • :profile (String) — default: "default"

    Used when loading credentials from the shared credentials file at HOME/.aws/credentials. When not specified, ‘default’ is used.

  • :require_https_for_sse_cpk (Boolean) — default: true

    When ‘true`, the endpoint must be HTTPS for all operations where server-side-encryption is used with customer-provided keys. This should only be disabled for local testing.

  • :retry_base_delay (Float) — default: 0.3

    The base delay in seconds used by the default backoff function.

  • :retry_jitter (Symbol) — default: :none

    A delay randomiser function used by the default backoff function. Some predefined functions can be referenced by name - :none, :equal, :full, otherwise a Proc that takes and returns a number.

    @see www.awsarchitectureblog.com/2015/03/backoff.html

  • :retry_limit (Integer) — default: 3

    The maximum number of times to retry failed requests. Only ~ 500 level server errors and certain ~ 400 level client errors are retried. Generally, these are throttling errors, data checksum errors, networking errors, timeout errors and auth errors from expired credentials.

  • :retry_max_delay (Integer) — default: 0

    The maximum number of seconds to delay between retries (0 for no limit) used by the default backoff function.

  • :secret_access_key (String)
  • :session_token (String)
  • :stub_responses (Boolean) — default: false

    Causes the client to return stubbed responses. By default fake responses are generated and returned. You can specify the response data to return or errors to raise by calling ClientStubs#stub_responses. See ClientStubs for more information.

    ** Please note ** When response stubbing is enabled, no HTTP requests are made, and retries are disabled.

  • :use_accelerate_endpoint (Boolean) — default: false

    When set to ‘true`, accelerated bucket endpoints will be used for all object operations. You must first enable accelerate for each bucket. [Go here for more information](docs.aws.amazon.com/AmazonS3/latest/dev/transfer-acceleration.html).

  • :use_dualstack_endpoint (Boolean) — default: false

    When set to ‘true`, IPv6-compatible bucket endpoints will be used for all operations.

  • :validate_params (Boolean) — default: true

    When ‘true`, request parameters are validated before sending the request.



261
262
263
# File 'lib/aws-sdk-s3/client.rb', line 261

def initialize(*args)
  super
end

Class Attribute Details

.identifierObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



7128
7129
7130
# File 'lib/aws-sdk-s3/client.rb', line 7128

def identifier
  @identifier
end

Class Method Details

.errors_moduleObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



7131
7132
7133
# File 'lib/aws-sdk-s3/client.rb', line 7131

def errors_module
  Errors
end

Instance Method Details

#abort_multipart_upload(params = {}) ⇒ Types::AbortMultipartUploadOutput

Aborts a multipart upload.

To verify that all parts have been removed, so you don’t get charged for the part storage, you should call the List Parts operation and ensure the parts list is empty.

Examples:

Example: To abort a multipart upload


# The following example aborts a multipart upload.

resp = client.abort_multipart_upload({
  bucket: "examplebucket", 
  key: "bigobject", 
  upload_id: "xadcOB_7YPBOJuoFiQ9cz4P3Pe6FIZwO4f7wN93uHsNBEw97pl5eNwzExg0LAT2dUN91cOmrEQHDsP3WA60CEg--", 
})

resp.to_h outputs the following:
{
}

Request syntax with placeholder values


resp = client.abort_multipart_upload({
  bucket: "BucketName", # required
  key: "ObjectKey", # required
  upload_id: "MultipartUploadId", # required
  request_payer: "requester", # accepts requester
})

Response structure


resp.request_charged #=> String, one of "requester"

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :bucket (required, String)
  • :key (required, String)
  • :upload_id (required, String)
  • :request_payer (String)

    Confirms that the requester knows that she or he will be charged for the request. Bucket owners need not specify this parameter in their requests. Documentation on downloading objects from requester pays buckets can be found at docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html

Returns:

See Also:



322
323
324
325
# File 'lib/aws-sdk-s3/client.rb', line 322

def abort_multipart_upload(params = {}, options = {})
  req = build_request(:abort_multipart_upload, params)
  req.send_request(options)
end

#build_request(operation_name, params = {}) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • params ({}) (defaults to: {})


6987
6988
6989
6990
6991
6992
6993
6994
6995
6996
6997
6998
# File 'lib/aws-sdk-s3/client.rb', line 6987

def build_request(operation_name, params = {})
  handlers = @handlers.for(operation_name)
  context = Seahorse::Client::RequestContext.new(
    operation_name: operation_name,
    operation: config.api.operation(operation_name),
    client: self,
    params: params,
    config: config)
  context[:gem_name] = 'aws-sdk-s3'
  context[:gem_version] = '1.31.0'
  Seahorse::Client::Request.new(handlers, context)
end

#complete_multipart_upload(params = {}) ⇒ Types::CompleteMultipartUploadOutput

Completes a multipart upload by assembling previously uploaded parts.

Examples:

Example: To complete multipart upload


# The following example completes a multipart upload.

resp = client.complete_multipart_upload({
  bucket: "examplebucket", 
  key: "bigobject", 
  multipart_upload: {
    parts: [
      {
        etag: "\"d8c2eafd90c266e19ab9dcacc479f8af\"", 
        part_number: 1, 
      }, 
      {
        etag: "\"d8c2eafd90c266e19ab9dcacc479f8af\"", 
        part_number: 2, 
      }, 
    ], 
  }, 
  upload_id: "7YPBOJuoFiQ9cz4P3Pe6FIZwO4f7wN93uHsNBEw97pl5eNwzExg0LAT2dUN91cOmrEQHDsP3WA60CEg--", 
})

resp.to_h outputs the following:
{
  bucket: "acexamplebucket", 
  etag: "\"4d9031c7644d8081c2829f4ea23c55f7-2\"", 
  key: "bigobject", 
  location: "https://examplebucket.s3.amazonaws.com/bigobject", 
}

Request syntax with placeholder values


resp = client.complete_multipart_upload({
  bucket: "BucketName", # required
  key: "ObjectKey", # required
  multipart_upload: {
    parts: [
      {
        etag: "ETag",
        part_number: 1,
      },
    ],
  },
  upload_id: "MultipartUploadId", # required
  request_payer: "requester", # accepts requester
})

Response structure


resp.location #=> String
resp.bucket #=> String
resp.key #=> String
resp.expiration #=> String
resp.etag #=> String
resp.server_side_encryption #=> String, one of "AES256", "aws:kms"
resp.version_id #=> String
resp.ssekms_key_id #=> String
resp.request_charged #=> String, one of "requester"

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

Returns:

See Also:



420
421
422
423
# File 'lib/aws-sdk-s3/client.rb', line 420

def complete_multipart_upload(params = {}, options = {})
  req = build_request(:complete_multipart_upload, params)
  req.send_request(options)
end

#copy_object(params = {}) ⇒ Types::CopyObjectOutput

Creates a copy of an object that is already stored in Amazon S3.

Examples:

Example: To copy an object


# The following example copies an object from one bucket to another.

resp = client.copy_object({
  bucket: "destinationbucket", 
  copy_source: "/sourcebucket/HappyFacejpg", 
  key: "HappyFaceCopyjpg", 
})

resp.to_h outputs the following:
{
  copy_object_result: {
    etag: "\"6805f2cfc46c0f04559748bb039d69ae\"", 
    last_modified: Time.parse("2016-12-15T17:38:53.000Z"), 
  }, 
}

Request syntax with placeholder values


resp = client.copy_object({
  acl: "private", # accepts private, public-read, public-read-write, authenticated-read, aws-exec-read, bucket-owner-read, bucket-owner-full-control
  bucket: "BucketName", # required
  cache_control: "CacheControl",
  content_disposition: "ContentDisposition",
  content_encoding: "ContentEncoding",
  content_language: "ContentLanguage",
  content_type: "ContentType",
  copy_source: "CopySource", # required
  copy_source_if_match: "CopySourceIfMatch",
  copy_source_if_modified_since: Time.now,
  copy_source_if_none_match: "CopySourceIfNoneMatch",
  copy_source_if_unmodified_since: Time.now,
  expires: Time.now,
  grant_full_control: "GrantFullControl",
  grant_read: "GrantRead",
  grant_read_acp: "GrantReadACP",
  grant_write_acp: "GrantWriteACP",
  key: "ObjectKey", # required
  metadata: {
    "MetadataKey" => "MetadataValue",
  },
  metadata_directive: "COPY", # accepts COPY, REPLACE
  tagging_directive: "COPY", # accepts COPY, REPLACE
  server_side_encryption: "AES256", # accepts AES256, aws:kms
  storage_class: "STANDARD", # accepts STANDARD, REDUCED_REDUNDANCY, STANDARD_IA, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER
  website_redirect_location: "WebsiteRedirectLocation",
  sse_customer_algorithm: "SSECustomerAlgorithm",
  sse_customer_key: "SSECustomerKey",
  sse_customer_key_md5: "SSECustomerKeyMD5",
  ssekms_key_id: "SSEKMSKeyId",
  copy_source_sse_customer_algorithm: "CopySourceSSECustomerAlgorithm",
  copy_source_sse_customer_key: "CopySourceSSECustomerKey",
  copy_source_sse_customer_key_md5: "CopySourceSSECustomerKeyMD5",
  request_payer: "requester", # accepts requester
  tagging: "TaggingHeader",
  object_lock_mode: "GOVERNANCE", # accepts GOVERNANCE, COMPLIANCE
  object_lock_retain_until_date: Time.now,
  object_lock_legal_hold_status: "ON", # accepts ON, OFF
})

Response structure


resp.copy_object_result.etag #=> String
resp.copy_object_result.last_modified #=> Time
resp.expiration #=> String
resp.copy_source_version_id #=> String
resp.version_id #=> String
resp.server_side_encryption #=> String, one of "AES256", "aws:kms"
resp.sse_customer_algorithm #=> String
resp.sse_customer_key_md5 #=> String
resp.ssekms_key_id #=> String
resp.request_charged #=> String, one of "requester"

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :acl (String)

    The canned ACL to apply to the object.

  • :bucket (required, String)
  • :cache_control (String)

    Specifies caching behavior along the request/reply chain.

  • :content_disposition (String)

    Specifies presentational information for the object.

  • :content_encoding (String)

    Specifies what content encodings have been applied to the object and thus what decoding mechanisms must be applied to obtain the media-type referenced by the Content-Type header field.

  • :content_language (String)

    The language the content is in.

  • :content_type (String)

    A standard MIME type describing the format of the object data.

  • :copy_source (required, String)

    The name of the source bucket and key name of the source object, separated by a slash (/). Must be URL-encoded.

  • :copy_source_if_match (String)

    Copies the object if its entity tag (ETag) matches the specified tag.

  • :copy_source_if_modified_since (Time, DateTime, Date, Integer, String)

    Copies the object if it has been modified since the specified time.

  • :copy_source_if_none_match (String)

    Copies the object if its entity tag (ETag) is different than the specified ETag.

  • :copy_source_if_unmodified_since (Time, DateTime, Date, Integer, String)

    Copies the object if it hasn’t been modified since the specified time.

  • :expires (Time, DateTime, Date, Integer, String)

    The date and time at which the object is no longer cacheable.

  • :grant_full_control (String)

    Gives the grantee READ, READ_ACP, and WRITE_ACP permissions on the object.

  • :grant_read (String)

    Allows grantee to read the object data and its metadata.

  • :grant_read_acp (String)

    Allows grantee to read the object ACL.

  • :grant_write_acp (String)

    Allows grantee to write the ACL for the applicable object.

  • :key (required, String)
  • :metadata (Hash<String,String>)

    A map of metadata to store with the object in S3.

  • :metadata_directive (String)

    Specifies whether the metadata is copied from the source object or replaced with metadata provided in the request.

  • :tagging_directive (String)

    Specifies whether the object tag-set are copied from the source object or replaced with tag-set provided in the request.

  • :server_side_encryption (String)

    The Server-side encryption algorithm used when storing this object in S3 (e.g., AES256, aws:kms).

  • :storage_class (String)

    The type of storage to use for the object. Defaults to ‘STANDARD’.

  • :website_redirect_location (String)

    If the bucket is configured as a website, redirects requests for this object to another object in the same bucket or to an external URL. Amazon S3 stores the value of this header in the object metadata.

  • :sse_customer_algorithm (String)

    Specifies the algorithm to use to when encrypting the object (e.g., AES256).

  • :sse_customer_key (String)

    Specifies the customer-provided encryption key for Amazon S3 to use in encrypting data. This value is used to store the object and then it is discarded; Amazon does not store the encryption key. The key must be appropriate for use with the algorithm specified in the x-amz-server-side​-encryption​-customer-algorithm header.

  • :sse_customer_key_md5 (String)

    Specifies the 128-bit MD5 digest of the encryption key according to RFC 1321. Amazon S3 uses this header for a message integrity check to ensure the encryption key was transmitted without error.

  • :ssekms_key_id (String)

    Specifies the AWS KMS key ID to use for object encryption. All GET and PUT requests for an object protected by AWS KMS will fail if not made via SSL or using SigV4. Documentation on configuring any of the officially supported AWS SDKs and CLI can be found at docs.aws.amazon.com/AmazonS3/latest/dev/UsingAWSSDK.html#specify-signature-version

  • :copy_source_sse_customer_algorithm (String)

    Specifies the algorithm to use when decrypting the source object (e.g., AES256).

  • :copy_source_sse_customer_key (String)

    Specifies the customer-provided encryption key for Amazon S3 to use to decrypt the source object. The encryption key provided in this header must be one that was used when the source object was created.

  • :copy_source_sse_customer_key_md5 (String)

    Specifies the 128-bit MD5 digest of the encryption key according to RFC 1321. Amazon S3 uses this header for a message integrity check to ensure the encryption key was transmitted without error.

  • :request_payer (String)

    Confirms that the requester knows that she or he will be charged for the request. Bucket owners need not specify this parameter in their requests. Documentation on downloading objects from requester pays buckets can be found at docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html

  • :tagging (String)

    The tag-set for the object destination object this value must be used in conjunction with the TaggingDirective. The tag-set must be encoded as URL Query parameters

  • :object_lock_mode (String)

    The Object Lock mode that you want to apply to the copied object.

  • :object_lock_retain_until_date (Time, DateTime, Date, Integer, String)

    The date and time when you want the copied object’s Object Lock to expire.

  • :object_lock_legal_hold_status (String)

    Specifies whether you want to apply a Legal Hold to the copied object.

Returns:

See Also:



658
659
660
661
# File 'lib/aws-sdk-s3/client.rb', line 658

def copy_object(params = {}, options = {})
  req = build_request(:copy_object, params)
  req.send_request(options)
end

#create_bucket(params = {}) ⇒ Types::CreateBucketOutput

Creates a new bucket.

Examples:

Example: To create a bucket


# The following example creates a bucket.

resp = client.create_bucket({
  bucket: "examplebucket", 
})

resp.to_h outputs the following:
{
  location: "/examplebucket", 
}

Example: To create a bucket in a specific region


# The following example creates a bucket. The request specifies an AWS region where to create the bucket.

resp = client.create_bucket({
  bucket: "examplebucket", 
  create_bucket_configuration: {
    location_constraint: "eu-west-1", 
  }, 
})

resp.to_h outputs the following:
{
  location: "http://examplebucket.s3.amazonaws.com/", 
}

Request syntax with placeholder values


resp = client.create_bucket({
  acl: "private", # accepts private, public-read, public-read-write, authenticated-read
  bucket: "BucketName", # required
  create_bucket_configuration: {
    location_constraint: "EU", # accepts EU, eu-west-1, us-west-1, us-west-2, ap-south-1, ap-southeast-1, ap-southeast-2, ap-northeast-1, sa-east-1, cn-north-1, eu-central-1
  },
  grant_full_control: "GrantFullControl",
  grant_read: "GrantRead",
  grant_read_acp: "GrantReadACP",
  grant_write: "GrantWrite",
  grant_write_acp: "GrantWriteACP",
  object_lock_enabled_for_bucket: false,
})

Response structure


resp.location #=> String

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :acl (String)

    The canned ACL to apply to the bucket.

  • :bucket (required, String)
  • :create_bucket_configuration (Types::CreateBucketConfiguration)
  • :grant_full_control (String)

    Allows grantee the read, write, read ACP, and write ACP permissions on the bucket.

  • :grant_read (String)

    Allows grantee to list the objects in the bucket.

  • :grant_read_acp (String)

    Allows grantee to read the bucket ACL.

  • :grant_write (String)

    Allows grantee to create, overwrite, and delete any object in the bucket.

  • :grant_write_acp (String)

    Allows grantee to write the ACL for the applicable bucket.

  • :object_lock_enabled_for_bucket (Boolean)

    Specifies whether you want S3 Object Lock to be enabled for the new bucket.

Returns:

See Also:



751
752
753
754
# File 'lib/aws-sdk-s3/client.rb', line 751

def create_bucket(params = {}, options = {})
  req = build_request(:create_bucket, params)
  req.send_request(options)
end

#create_multipart_upload(params = {}) ⇒ Types::CreateMultipartUploadOutput

Initiates a multipart upload and returns an upload ID.

Note: After you initiate multipart upload and upload one or more parts, you must either complete or abort multipart upload in order to stop getting charged for storage of the uploaded parts. Only after you either complete or abort multipart upload, Amazon S3 frees up the parts storage and stops charging you for the parts storage.

Examples:

Example: To initiate a multipart upload


# The following example initiates a multipart upload.

resp = client.create_multipart_upload({
  bucket: "examplebucket", 
  key: "largeobject", 
})

resp.to_h outputs the following:
{
  bucket: "examplebucket", 
  key: "largeobject", 
  upload_id: "ibZBv_75gd9r8lH_gqXatLdxMVpAlj6ZQjEs.OwyF3953YdwbcQnMA2BLGn8Lx12fQNICtMw5KyteFeHw.Sjng--", 
}

Request syntax with placeholder values


resp = client.create_multipart_upload({
  acl: "private", # accepts private, public-read, public-read-write, authenticated-read, aws-exec-read, bucket-owner-read, bucket-owner-full-control
  bucket: "BucketName", # required
  cache_control: "CacheControl",
  content_disposition: "ContentDisposition",
  content_encoding: "ContentEncoding",
  content_language: "ContentLanguage",
  content_type: "ContentType",
  expires: Time.now,
  grant_full_control: "GrantFullControl",
  grant_read: "GrantRead",
  grant_read_acp: "GrantReadACP",
  grant_write_acp: "GrantWriteACP",
  key: "ObjectKey", # required
  metadata: {
    "MetadataKey" => "MetadataValue",
  },
  server_side_encryption: "AES256", # accepts AES256, aws:kms
  storage_class: "STANDARD", # accepts STANDARD, REDUCED_REDUNDANCY, STANDARD_IA, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER
  website_redirect_location: "WebsiteRedirectLocation",
  sse_customer_algorithm: "SSECustomerAlgorithm",
  sse_customer_key: "SSECustomerKey",
  sse_customer_key_md5: "SSECustomerKeyMD5",
  ssekms_key_id: "SSEKMSKeyId",
  request_payer: "requester", # accepts requester
  tagging: "TaggingHeader",
  object_lock_mode: "GOVERNANCE", # accepts GOVERNANCE, COMPLIANCE
  object_lock_retain_until_date: Time.now,
  object_lock_legal_hold_status: "ON", # accepts ON, OFF
})

Response structure


resp.abort_date #=> Time
resp.abort_rule_id #=> String
resp.bucket #=> String
resp.key #=> String
resp.upload_id #=> String
resp.server_side_encryption #=> String, one of "AES256", "aws:kms"
resp.sse_customer_algorithm #=> String
resp.sse_customer_key_md5 #=> String
resp.ssekms_key_id #=> String
resp.request_charged #=> String, one of "requester"

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :acl (String)

    The canned ACL to apply to the object.

  • :bucket (required, String)
  • :cache_control (String)

    Specifies caching behavior along the request/reply chain.

  • :content_disposition (String)

    Specifies presentational information for the object.

  • :content_encoding (String)

    Specifies what content encodings have been applied to the object and thus what decoding mechanisms must be applied to obtain the media-type referenced by the Content-Type header field.

  • :content_language (String)

    The language the content is in.

  • :content_type (String)

    A standard MIME type describing the format of the object data.

  • :expires (Time, DateTime, Date, Integer, String)

    The date and time at which the object is no longer cacheable.

  • :grant_full_control (String)

    Gives the grantee READ, READ_ACP, and WRITE_ACP permissions on the object.

  • :grant_read (String)

    Allows grantee to read the object data and its metadata.

  • :grant_read_acp (String)

    Allows grantee to read the object ACL.

  • :grant_write_acp (String)

    Allows grantee to write the ACL for the applicable object.

  • :key (required, String)
  • :metadata (Hash<String,String>)

    A map of metadata to store with the object in S3.

  • :server_side_encryption (String)

    The Server-side encryption algorithm used when storing this object in S3 (e.g., AES256, aws:kms).

  • :storage_class (String)

    The type of storage to use for the object. Defaults to ‘STANDARD’.

  • :website_redirect_location (String)

    If the bucket is configured as a website, redirects requests for this object to another object in the same bucket or to an external URL. Amazon S3 stores the value of this header in the object metadata.

  • :sse_customer_algorithm (String)

    Specifies the algorithm to use to when encrypting the object (e.g., AES256).

  • :sse_customer_key (String)

    Specifies the customer-provided encryption key for Amazon S3 to use in encrypting data. This value is used to store the object and then it is discarded; Amazon does not store the encryption key. The key must be appropriate for use with the algorithm specified in the x-amz-server-side​-encryption​-customer-algorithm header.

  • :sse_customer_key_md5 (String)

    Specifies the 128-bit MD5 digest of the encryption key according to RFC 1321. Amazon S3 uses this header for a message integrity check to ensure the encryption key was transmitted without error.

  • :ssekms_key_id (String)

    Specifies the AWS KMS key ID to use for object encryption. All GET and PUT requests for an object protected by AWS KMS will fail if not made via SSL or using SigV4. Documentation on configuring any of the officially supported AWS SDKs and CLI can be found at docs.aws.amazon.com/AmazonS3/latest/dev/UsingAWSSDK.html#specify-signature-version

  • :request_payer (String)

    Confirms that the requester knows that she or he will be charged for the request. Bucket owners need not specify this parameter in their requests. Documentation on downloading objects from requester pays buckets can be found at docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html

  • :tagging (String)

    The tag-set for the object. The tag-set must be encoded as URL Query parameters

  • :object_lock_mode (String)

    Specifies the Object Lock mode that you want to apply to the uploaded object.

  • :object_lock_retain_until_date (Time, DateTime, Date, Integer, String)

    Specifies the date and time when you want the Object Lock to expire.

  • :object_lock_legal_hold_status (String)

    Specifies whether you want to apply a Legal Hold to the uploaded object.

Returns:

See Also:



944
945
946
947
# File 'lib/aws-sdk-s3/client.rb', line 944

def create_multipart_upload(params = {}, options = {})
  req = build_request(:create_multipart_upload, params)
  req.send_request(options)
end

#delete_bucket(params = {}) ⇒ Struct

Deletes the bucket. All objects (including all object versions and Delete Markers) in the bucket must be deleted before the bucket itself can be deleted.

Examples:

Example: To delete a bucket


# The following example deletes the specified bucket.

resp = client.delete_bucket({
  bucket: "forrandall2", 
})

Request syntax with placeholder values


resp = client.delete_bucket({
  bucket: "BucketName", # required
})

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :bucket (required, String)

Returns:

  • (Struct)

    Returns an empty response.

See Also:



976
977
978
979
# File 'lib/aws-sdk-s3/client.rb', line 976

def delete_bucket(params = {}, options = {})
  req = build_request(:delete_bucket, params)
  req.send_request(options)
end

#delete_bucket_analytics_configuration(params = {}) ⇒ Struct

Deletes an analytics configuration for the bucket (specified by the analytics configuration ID).

Examples:

Request syntax with placeholder values


resp = client.delete_bucket_analytics_configuration({
  bucket: "BucketName", # required
  id: "AnalyticsId", # required
})

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :bucket (required, String)

    The name of the bucket from which an analytics configuration is deleted.

  • :id (required, String)

    The identifier used to represent an analytics configuration.

Returns:

  • (Struct)

    Returns an empty response.

See Also:



1004
1005
1006
1007
# File 'lib/aws-sdk-s3/client.rb', line 1004

def delete_bucket_analytics_configuration(params = {}, options = {})
  req = build_request(:delete_bucket_analytics_configuration, params)
  req.send_request(options)
end

#delete_bucket_cors(params = {}) ⇒ Struct

Deletes the CORS configuration information set for the bucket.

Examples:

Example: To delete cors configuration on a bucket.


# The following example deletes CORS configuration on a bucket.

resp = client.delete_bucket_cors({
  bucket: "examplebucket", 
})

Request syntax with placeholder values


resp = client.delete_bucket_cors({
  bucket: "BucketName", # required
})

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :bucket (required, String)

Returns:

  • (Struct)

    Returns an empty response.

See Also:



1034
1035
1036
1037
# File 'lib/aws-sdk-s3/client.rb', line 1034

def delete_bucket_cors(params = {}, options = {})
  req = build_request(:delete_bucket_cors, params)
  req.send_request(options)
end

#delete_bucket_encryption(params = {}) ⇒ Struct

Deletes the server-side encryption configuration from the bucket.

Examples:

Request syntax with placeholder values


resp = client.delete_bucket_encryption({
  bucket: "BucketName", # required
})

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :bucket (required, String)

    The name of the bucket containing the server-side encryption configuration to delete.

Returns:

  • (Struct)

    Returns an empty response.

See Also:



1057
1058
1059
1060
# File 'lib/aws-sdk-s3/client.rb', line 1057

def delete_bucket_encryption(params = {}, options = {})
  req = build_request(:delete_bucket_encryption, params)
  req.send_request(options)
end

#delete_bucket_inventory_configuration(params = {}) ⇒ Struct

Deletes an inventory configuration (identified by the inventory ID) from the bucket.

Examples:

Request syntax with placeholder values


resp = client.delete_bucket_inventory_configuration({
  bucket: "BucketName", # required
  id: "InventoryId", # required
})

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :bucket (required, String)

    The name of the bucket containing the inventory configuration to delete.

  • :id (required, String)

    The ID used to identify the inventory configuration.

Returns:

  • (Struct)

    Returns an empty response.

See Also:



1085
1086
1087
1088
# File 'lib/aws-sdk-s3/client.rb', line 1085

def delete_bucket_inventory_configuration(params = {}, options = {})
  req = build_request(:delete_bucket_inventory_configuration, params)
  req.send_request(options)
end

#delete_bucket_lifecycle(params = {}) ⇒ Struct

Deletes the lifecycle configuration from the bucket.

Examples:

Example: To delete lifecycle configuration on a bucket.


# The following example deletes lifecycle configuration on a bucket.

resp = client.delete_bucket_lifecycle({
  bucket: "examplebucket", 
})

Request syntax with placeholder values


resp = client.delete_bucket_lifecycle({
  bucket: "BucketName", # required
})

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :bucket (required, String)

Returns:

  • (Struct)

    Returns an empty response.

See Also:



1115
1116
1117
1118
# File 'lib/aws-sdk-s3/client.rb', line 1115

def delete_bucket_lifecycle(params = {}, options = {})
  req = build_request(:delete_bucket_lifecycle, params)
  req.send_request(options)
end

#delete_bucket_metrics_configuration(params = {}) ⇒ Struct

Deletes a metrics configuration (specified by the metrics configuration ID) from the bucket.

Examples:

Request syntax with placeholder values


resp = client.delete_bucket_metrics_configuration({
  bucket: "BucketName", # required
  id: "MetricsId", # required
})

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :bucket (required, String)

    The name of the bucket containing the metrics configuration to delete.

  • :id (required, String)

    The ID used to identify the metrics configuration.

Returns:

  • (Struct)

    Returns an empty response.

See Also:



1142
1143
1144
1145
# File 'lib/aws-sdk-s3/client.rb', line 1142

def delete_bucket_metrics_configuration(params = {}, options = {})
  req = build_request(:delete_bucket_metrics_configuration, params)
  req.send_request(options)
end

#delete_bucket_policy(params = {}) ⇒ Struct

Deletes the policy from the bucket.

Examples:

Example: To delete bucket policy


# The following example deletes bucket policy on the specified bucket.

resp = client.delete_bucket_policy({
  bucket: "examplebucket", 
})

Request syntax with placeholder values


resp = client.delete_bucket_policy({
  bucket: "BucketName", # required
})

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :bucket (required, String)

Returns:

  • (Struct)

    Returns an empty response.

See Also:



1172
1173
1174
1175
# File 'lib/aws-sdk-s3/client.rb', line 1172

def delete_bucket_policy(params = {}, options = {})
  req = build_request(:delete_bucket_policy, params)
  req.send_request(options)
end

#delete_bucket_replication(params = {}) ⇒ Struct

Deletes the replication configuration from the bucket. For information about replication configuration, see [Cross-Region Replication (CRR)]( docs.aws.amazon.com/AmazonS3/latest/dev/crr.html) in the *Amazon S3 Developer Guide*.

Examples:

Example: To delete bucket replication configuration


# The following example deletes replication configuration set on bucket.

resp = client.delete_bucket_replication({
  bucket: "example", 
})

Request syntax with placeholder values


resp = client.delete_bucket_replication({
  bucket: "BucketName", # required
})

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :bucket (required, String)

    The bucket name.

    <note markdown=“1”> It can take a while to propagate the deletion of a replication configuration to all Amazon S3 systems.

    </note>
    

Returns:

  • (Struct)

    Returns an empty response.

See Also:



1211
1212
1213
1214
# File 'lib/aws-sdk-s3/client.rb', line 1211

def delete_bucket_replication(params = {}, options = {})
  req = build_request(:delete_bucket_replication, params)
  req.send_request(options)
end

#delete_bucket_tagging(params = {}) ⇒ Struct

Deletes the tags from the bucket.

Examples:

Example: To delete bucket tags


# The following example deletes bucket tags.

resp = client.delete_bucket_tagging({
  bucket: "examplebucket", 
})

Request syntax with placeholder values


resp = client.delete_bucket_tagging({
  bucket: "BucketName", # required
})

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :bucket (required, String)

Returns:

  • (Struct)

    Returns an empty response.

See Also:



1241
1242
1243
1244
# File 'lib/aws-sdk-s3/client.rb', line 1241

def delete_bucket_tagging(params = {}, options = {})
  req = build_request(:delete_bucket_tagging, params)
  req.send_request(options)
end

#delete_bucket_website(params = {}) ⇒ Struct

This operation removes the website configuration from the bucket.

Examples:

Example: To delete bucket website configuration


# The following example deletes bucket website configuration.

resp = client.delete_bucket_website({
  bucket: "examplebucket", 
})

Request syntax with placeholder values


resp = client.delete_bucket_website({
  bucket: "BucketName", # required
})

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :bucket (required, String)

Returns:

  • (Struct)

    Returns an empty response.

See Also:



1271
1272
1273
1274
# File 'lib/aws-sdk-s3/client.rb', line 1271

def delete_bucket_website(params = {}, options = {})
  req = build_request(:delete_bucket_website, params)
  req.send_request(options)
end

#delete_object(params = {}) ⇒ Types::DeleteObjectOutput

Removes the null version (if there is one) of an object and inserts a delete marker, which becomes the latest version of the object. If there isn’t a null version, Amazon S3 does not remove any objects.

Examples:

Example: To delete an object (from a non-versioned bucket)


# The following example deletes an object from a non-versioned bucket.

resp = client.delete_object({
  bucket: "ExampleBucket", 
  key: "HappyFace.jpg", 
})

Example: To delete an object


# The following example deletes an object from an S3 bucket.

resp = client.delete_object({
  bucket: "examplebucket", 
  key: "objectkey.jpg", 
})

resp.to_h outputs the following:
{
}

Request syntax with placeholder values


resp = client.delete_object({
  bucket: "BucketName", # required
  key: "ObjectKey", # required
  mfa: "MFA",
  version_id: "ObjectVersionId",
  request_payer: "requester", # accepts requester
  bypass_governance_retention: false,
})

Response structure


resp.delete_marker #=> Boolean
resp.version_id #=> String
resp.request_charged #=> String, one of "requester"

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :bucket (required, String)
  • :key (required, String)
  • :mfa (String)

    The concatenation of the authentication device’s serial number, a space, and the value that is displayed on your authentication device.

  • :version_id (String)

    VersionId used to reference a specific version of the object.

  • :request_payer (String)

    Confirms that the requester knows that she or he will be charged for the request. Bucket owners need not specify this parameter in their requests. Documentation on downloading objects from requester pays buckets can be found at docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html

  • :bypass_governance_retention (Boolean)

    Indicates whether S3 Object Lock should bypass Governance-mode restrictions to process this operation.

Returns:

See Also:



1352
1353
1354
1355
# File 'lib/aws-sdk-s3/client.rb', line 1352

def delete_object(params = {}, options = {})
  req = build_request(:delete_object, params)
  req.send_request(options)
end

#delete_object_tagging(params = {}) ⇒ Types::DeleteObjectTaggingOutput

Removes the tag-set from an existing object.

Examples:

Example: To remove tag set from an object


# The following example removes tag set associated with the specified object. If the bucket is versioning enabled, the
# operation removes tag set from the latest object version.

resp = client.delete_object_tagging({
  bucket: "examplebucket", 
  key: "HappyFace.jpg", 
})

resp.to_h outputs the following:
{
  version_id: "null", 
}

Example: To remove tag set from an object version


# The following example removes tag set associated with the specified object version. The request specifies both the
# object key and object version.

resp = client.delete_object_tagging({
  bucket: "examplebucket", 
  key: "HappyFace.jpg", 
  version_id: "ydlaNkwWm0SfKJR.T1b1fIdPRbldTYRI", 
})

resp.to_h outputs the following:
{
  version_id: "ydlaNkwWm0SfKJR.T1b1fIdPRbldTYRI", 
}

Request syntax with placeholder values


resp = client.delete_object_tagging({
  bucket: "BucketName", # required
  key: "ObjectKey", # required
  version_id: "ObjectVersionId",
})

Response structure


resp.version_id #=> String

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :bucket (required, String)
  • :key (required, String)
  • :version_id (String)

    The versionId of the object that the tag-set will be removed from.

Returns:

See Also:



1418
1419
1420
1421
# File 'lib/aws-sdk-s3/client.rb', line 1418

def delete_object_tagging(params = {}, options = {})
  req = build_request(:delete_object_tagging, params)
  req.send_request(options)
end

#delete_objects(params = {}) ⇒ Types::DeleteObjectsOutput

This operation enables you to delete multiple objects from a bucket using a single HTTP request. You may specify up to 1000 keys.

Examples:

Example: To delete multiple objects from a versioned bucket


# The following example deletes objects from a bucket. The bucket is versioned, and the request does not specify the
# object version to delete. In this case, all versions remain in the bucket and S3 adds a delete marker.

resp = client.delete_objects({
  bucket: "examplebucket", 
  delete: {
    objects: [
      {
        key: "objectkey1", 
      }, 
      {
        key: "objectkey2", 
      }, 
    ], 
    quiet: false, 
  }, 
})

resp.to_h outputs the following:
{
  deleted: [
    {
      delete_marker: true, 
      delete_marker_version_id: "A._w1z6EFiCF5uhtQMDal9JDkID9tQ7F", 
      key: "objectkey1", 
    }, 
    {
      delete_marker: true, 
      delete_marker_version_id: "iOd_ORxhkKe_e8G8_oSGxt2PjsCZKlkt", 
      key: "objectkey2", 
    }, 
  ], 
}

Example: To delete multiple object versions from a versioned bucket


# The following example deletes objects from a bucket. The request specifies object versions. S3 deletes specific object
# versions and returns the key and versions of deleted objects in the response.

resp = client.delete_objects({
  bucket: "examplebucket", 
  delete: {
    objects: [
      {
        key: "HappyFace.jpg", 
        version_id: "2LWg7lQLnY41.maGB5Z6SWW.dcq0vx7b", 
      }, 
      {
        key: "HappyFace.jpg", 
        version_id: "yoz3HB.ZhCS_tKVEmIOr7qYyyAaZSKVd", 
      }, 
    ], 
    quiet: false, 
  }, 
})

resp.to_h outputs the following:
{
  deleted: [
    {
      key: "HappyFace.jpg", 
      version_id: "yoz3HB.ZhCS_tKVEmIOr7qYyyAaZSKVd", 
    }, 
    {
      key: "HappyFace.jpg", 
      version_id: "2LWg7lQLnY41.maGB5Z6SWW.dcq0vx7b", 
    }, 
  ], 
}

Request syntax with placeholder values


resp = client.delete_objects({
  bucket: "BucketName", # required
  delete: { # required
    objects: [ # required
      {
        key: "ObjectKey", # required
        version_id: "ObjectVersionId",
      },
    ],
    quiet: false,
  },
  mfa: "MFA",
  request_payer: "requester", # accepts requester
  bypass_governance_retention: false,
})

Response structure


resp.deleted #=> Array
resp.deleted[0].key #=> String
resp.deleted[0].version_id #=> String
resp.deleted[0].delete_marker #=> Boolean
resp.deleted[0].delete_marker_version_id #=> String
resp.request_charged #=> String, one of "requester"
resp.errors #=> Array
resp.errors[0].key #=> String
resp.errors[0].version_id #=> String
resp.errors[0].code #=> String
resp.errors[0].message #=> String

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :bucket (required, String)
  • :delete (required, Types::Delete)
  • :mfa (String)

    The concatenation of the authentication device’s serial number, a space, and the value that is displayed on your authentication device.

  • :request_payer (String)

    Confirms that the requester knows that she or he will be charged for the request. Bucket owners need not specify this parameter in their requests. Documentation on downloading objects from requester pays buckets can be found at docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html

  • :bypass_governance_retention (Boolean)

    Specifies whether you want to delete this object even if it has a Governance-type Object Lock in place. You must have sufficient permissions to perform this operation.

Returns:

See Also:



1561
1562
1563
1564
# File 'lib/aws-sdk-s3/client.rb', line 1561

def delete_objects(params = {}, options = {})
  req = build_request(:delete_objects, params)
  req.send_request(options)
end

#delete_public_access_block(params = {}) ⇒ Struct

Removes the ‘PublicAccessBlock` configuration from an Amazon S3 bucket.

Examples:

Request syntax with placeholder values


resp = client.delete_public_access_block({
  bucket: "BucketName", # required
})

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :bucket (required, String)

    The Amazon S3 bucket whose ‘PublicAccessBlock` configuration you want to delete.

Returns:

  • (Struct)

    Returns an empty response.

See Also:



1585
1586
1587
1588
# File 'lib/aws-sdk-s3/client.rb', line 1585

def delete_public_access_block(params = {}, options = {})
  req = build_request(:delete_public_access_block, params)
  req.send_request(options)
end

#get_bucket_accelerate_configuration(params = {}) ⇒ Types::GetBucketAccelerateConfigurationOutput

Returns the accelerate configuration of a bucket.

Examples:

Request syntax with placeholder values


resp = client.get_bucket_accelerate_configuration({
  bucket: "BucketName", # required
})

Response structure


resp.status #=> String, one of "Enabled", "Suspended"

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :bucket (required, String)

    Name of the bucket for which the accelerate configuration is retrieved.

Returns:

See Also:



1614
1615
1616
1617
# File 'lib/aws-sdk-s3/client.rb', line 1614

def get_bucket_accelerate_configuration(params = {}, options = {})
  req = build_request(:get_bucket_accelerate_configuration, params)
  req.send_request(options)
end

#get_bucket_acl(params = {}) ⇒ Types::GetBucketAclOutput

Gets the access control policy for the bucket.

Examples:

Request syntax with placeholder values


resp = client.get_bucket_acl({
  bucket: "BucketName", # required
})

Response structure


resp.owner.display_name #=> String
resp.owner.id #=> String
resp.grants #=> Array
resp.grants[0].grantee.display_name #=> String
resp.grants[0].grantee.email_address #=> String
resp.grants[0].grantee.id #=> String
resp.grants[0].grantee.type #=> String, one of "CanonicalUser", "AmazonCustomerByEmail", "Group"
resp.grants[0].grantee.uri #=> String
resp.grants[0].permission #=> String, one of "FULL_CONTROL", "WRITE", "WRITE_ACP", "READ", "READ_ACP"

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :bucket (required, String)

Returns:

See Also:



1650
1651
1652
1653
# File 'lib/aws-sdk-s3/client.rb', line 1650

def get_bucket_acl(params = {}, options = {})
  req = build_request(:get_bucket_acl, params)
  req.send_request(options)
end

#get_bucket_analytics_configuration(params = {}) ⇒ Types::GetBucketAnalyticsConfigurationOutput

Gets an analytics configuration for the bucket (specified by the analytics configuration ID).

Examples:

Request syntax with placeholder values


resp = client.get_bucket_analytics_configuration({
  bucket: "BucketName", # required
  id: "AnalyticsId", # required
})

Response structure


resp.analytics_configuration.id #=> String
resp.analytics_configuration.filter.prefix #=> String
resp.analytics_configuration.filter.tag.key #=> String
resp.analytics_configuration.filter.tag.value #=> String
resp.analytics_configuration.filter.and.prefix #=> String
resp.analytics_configuration.filter.and.tags #=> Array
resp.analytics_configuration.filter.and.tags[0].key #=> String
resp.analytics_configuration.filter.and.tags[0].value #=> String
resp.analytics_configuration.storage_class_analysis.data_export.output_schema_version #=> String, one of "V_1"
resp.analytics_configuration.storage_class_analysis.data_export.destination.s3_bucket_destination.format #=> String, one of "CSV"
resp.analytics_configuration.storage_class_analysis.data_export.destination.s3_bucket_destination. #=> String
resp.analytics_configuration.storage_class_analysis.data_export.destination.s3_bucket_destination.bucket #=> String
resp.analytics_configuration.storage_class_analysis.data_export.destination.s3_bucket_destination.prefix #=> String

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :bucket (required, String)

    The name of the bucket from which an analytics configuration is retrieved.

  • :id (required, String)

    The identifier used to represent an analytics configuration.

Returns:

See Also:



1696
1697
1698
1699
# File 'lib/aws-sdk-s3/client.rb', line 1696

def get_bucket_analytics_configuration(params = {}, options = {})
  req = build_request(:get_bucket_analytics_configuration, params)
  req.send_request(options)
end

#get_bucket_cors(params = {}) ⇒ Types::GetBucketCorsOutput

Returns the CORS configuration for the bucket.

Examples:

Example: To get cors configuration set on a bucket


# The following example returns cross-origin resource sharing (CORS) configuration set on a bucket.

resp = client.get_bucket_cors({
  bucket: "examplebucket", 
})

resp.to_h outputs the following:
{
  cors_rules: [
    {
      allowed_headers: [
        "Authorization", 
      ], 
      allowed_methods: [
        "GET", 
      ], 
      allowed_origins: [
        "*", 
      ], 
      max_age_seconds: 3000, 
    }, 
  ], 
}

Request syntax with placeholder values


resp = client.get_bucket_cors({
  bucket: "BucketName", # required
})

Response structure


resp.cors_rules #=> Array
resp.cors_rules[0].allowed_headers #=> Array
resp.cors_rules[0].allowed_headers[0] #=> String
resp.cors_rules[0].allowed_methods #=> Array
resp.cors_rules[0].allowed_methods[0] #=> String
resp.cors_rules[0].allowed_origins #=> Array
resp.cors_rules[0].allowed_origins[0] #=> String
resp.cors_rules[0].expose_headers #=> Array
resp.cors_rules[0].expose_headers[0] #=> String
resp.cors_rules[0].max_age_seconds #=> Integer

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :bucket (required, String)

Returns:

See Also:



1759
1760
1761
1762
# File 'lib/aws-sdk-s3/client.rb', line 1759

def get_bucket_cors(params = {}, options = {})
  req = build_request(:get_bucket_cors, params)
  req.send_request(options)
end

#get_bucket_encryption(params = {}) ⇒ Types::GetBucketEncryptionOutput

Returns the server-side encryption configuration of a bucket.

Examples:

Request syntax with placeholder values


resp = client.get_bucket_encryption({
  bucket: "BucketName", # required
})

Response structure


resp.server_side_encryption_configuration.rules #=> Array
resp.server_side_encryption_configuration.rules[0].apply_server_side_encryption_by_default.sse_algorithm #=> String, one of "AES256", "aws:kms"
resp.server_side_encryption_configuration.rules[0].apply_server_side_encryption_by_default.kms_master_key_id #=> String

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :bucket (required, String)

    The name of the bucket from which the server-side encryption configuration is retrieved.

Returns:

See Also:



1790
1791
1792
1793
# File 'lib/aws-sdk-s3/client.rb', line 1790

def get_bucket_encryption(params = {}, options = {})
  req = build_request(:get_bucket_encryption, params)
  req.send_request(options)
end

#get_bucket_inventory_configuration(params = {}) ⇒ Types::GetBucketInventoryConfigurationOutput

Returns an inventory configuration (identified by the inventory ID) from the bucket.

Examples:

Request syntax with placeholder values


resp = client.get_bucket_inventory_configuration({
  bucket: "BucketName", # required
  id: "InventoryId", # required
})

Response structure


resp.inventory_configuration.destination.s3_bucket_destination. #=> String
resp.inventory_configuration.destination.s3_bucket_destination.bucket #=> String
resp.inventory_configuration.destination.s3_bucket_destination.format #=> String, one of "CSV", "ORC", "Parquet"
resp.inventory_configuration.destination.s3_bucket_destination.prefix #=> String
resp.inventory_configuration.destination.s3_bucket_destination.encryption.ssekms.key_id #=> String
resp.inventory_configuration.is_enabled #=> Boolean
resp.inventory_configuration.filter.prefix #=> String
resp.inventory_configuration.id #=> String
resp.inventory_configuration.included_object_versions #=> String, one of "All", "Current"
resp.inventory_configuration.optional_fields #=> Array
resp.inventory_configuration.optional_fields[0] #=> String, one of "Size", "LastModifiedDate", "StorageClass", "ETag", "IsMultipartUploaded", "ReplicationStatus", "EncryptionStatus", "ObjectLockRetainUntilDate", "ObjectLockMode", "ObjectLockLegalHoldStatus"
resp.inventory_configuration.schedule.frequency #=> String, one of "Daily", "Weekly"

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :bucket (required, String)

    The name of the bucket containing the inventory configuration to retrieve.

  • :id (required, String)

    The ID used to identify the inventory configuration.

Returns:

See Also:



1835
1836
1837
1838
# File 'lib/aws-sdk-s3/client.rb', line 1835

def get_bucket_inventory_configuration(params = {}, options = {})
  req = build_request(:get_bucket_inventory_configuration, params)
  req.send_request(options)
end

#get_bucket_lifecycle(params = {}) ⇒ Types::GetBucketLifecycleOutput

No longer used, see the GetBucketLifecycleConfiguration operation.

Examples:

Example: To get a bucket acl


# The following example gets ACL on the specified bucket.

resp = client.get_bucket_lifecycle({
  bucket: "acl1", 
})

resp.to_h outputs the following:
{
  rules: [
    {
      expiration: {
        days: 1, 
      }, 
      id: "delete logs", 
      prefix: "123/", 
      status: "Enabled", 
    }, 
  ], 
}

Request syntax with placeholder values


resp = client.get_bucket_lifecycle({
  bucket: "BucketName", # required
})

Response structure


resp.rules #=> Array
resp.rules[0].expiration.date #=> Time
resp.rules[0].expiration.days #=> Integer
resp.rules[0].expiration.expired_object_delete_marker #=> Boolean
resp.rules[0].id #=> String
resp.rules[0].prefix #=> String
resp.rules[0].status #=> String, one of "Enabled", "Disabled"
resp.rules[0].transition.date #=> Time
resp.rules[0].transition.days #=> Integer
resp.rules[0].transition.storage_class #=> String, one of "GLACIER", "STANDARD_IA", "ONEZONE_IA", "INTELLIGENT_TIERING"
resp.rules[0].noncurrent_version_transition.noncurrent_days #=> Integer
resp.rules[0].noncurrent_version_transition.storage_class #=> String, one of "GLACIER", "STANDARD_IA", "ONEZONE_IA", "INTELLIGENT_TIERING"
resp.rules[0].noncurrent_version_expiration.noncurrent_days #=> Integer
resp.rules[0].abort_incomplete_multipart_upload.days_after_initiation #=> Integer

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :bucket (required, String)

Returns:

See Also:



1898
1899
1900
1901
# File 'lib/aws-sdk-s3/client.rb', line 1898

def get_bucket_lifecycle(params = {}, options = {})
  req = build_request(:get_bucket_lifecycle, params)
  req.send_request(options)
end

#get_bucket_lifecycle_configuration(params = {}) ⇒ Types::GetBucketLifecycleConfigurationOutput

Returns the lifecycle configuration information set on the bucket.

Examples:

Example: To get lifecycle configuration on a bucket


# The following example retrieves lifecycle configuration on set on a bucket. 

resp = client.get_bucket_lifecycle_configuration({
  bucket: "examplebucket", 
})

resp.to_h outputs the following:
{
  rules: [
    {
      id: "Rule for TaxDocs/", 
      prefix: "TaxDocs", 
      status: "Enabled", 
      transitions: [
        {
          days: 365, 
          storage_class: "STANDARD_IA", 
        }, 
      ], 
    }, 
  ], 
}

Request syntax with placeholder values


resp = client.get_bucket_lifecycle_configuration({
  bucket: "BucketName", # required
})

Response structure


resp.rules #=> Array
resp.rules[0].expiration.date #=> Time
resp.rules[0].expiration.days #=> Integer
resp.rules[0].expiration.expired_object_delete_marker #=> Boolean
resp.rules[0].id #=> String
resp.rules[0].prefix #=> String
resp.rules[0].filter.prefix #=> String
resp.rules[0].filter.tag.key #=> String
resp.rules[0].filter.tag.value #=> String
resp.rules[0].filter.and.prefix #=> String
resp.rules[0].filter.and.tags #=> Array
resp.rules[0].filter.and.tags[0].key #=> String
resp.rules[0].filter.and.tags[0].value #=> String
resp.rules[0].status #=> String, one of "Enabled", "Disabled"
resp.rules[0].transitions #=> Array
resp.rules[0].transitions[0].date #=> Time
resp.rules[0].transitions[0].days #=> Integer
resp.rules[0].transitions[0].storage_class #=> String, one of "GLACIER", "STANDARD_IA", "ONEZONE_IA", "INTELLIGENT_TIERING"
resp.rules[0].noncurrent_version_transitions #=> Array
resp.rules[0].noncurrent_version_transitions[0].noncurrent_days #=> Integer
resp.rules[0].noncurrent_version_transitions[0].storage_class #=> String, one of "GLACIER", "STANDARD_IA", "ONEZONE_IA", "INTELLIGENT_TIERING"
resp.rules[0].noncurrent_version_expiration.noncurrent_days #=> Integer
resp.rules[0].abort_incomplete_multipart_upload.days_after_initiation #=> Integer

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :bucket (required, String)

Returns:

See Also:



1973
1974
1975
1976
# File 'lib/aws-sdk-s3/client.rb', line 1973

def get_bucket_lifecycle_configuration(params = {}, options = {})
  req = build_request(:get_bucket_lifecycle_configuration, params)
  req.send_request(options)
end

#get_bucket_location(params = {}) ⇒ Types::GetBucketLocationOutput

Returns the region the bucket resides in.

Examples:

Example: To get bucket location


# The following example returns bucket location.

resp = client.get_bucket_location({
  bucket: "examplebucket", 
})

resp.to_h outputs the following:
{
  location_constraint: "us-west-2", 
}

Request syntax with placeholder values


resp = client.get_bucket_location({
  bucket: "BucketName", # required
})

Response structure


resp.location_constraint #=> String, one of "EU", "eu-west-1", "us-west-1", "us-west-2", "ap-south-1", "ap-southeast-1", "ap-southeast-2", "ap-northeast-1", "sa-east-1", "cn-north-1", "eu-central-1"

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :bucket (required, String)

Returns:

See Also:



2014
2015
2016
2017
# File 'lib/aws-sdk-s3/client.rb', line 2014

def get_bucket_location(params = {}, options = {})
  req = build_request(:get_bucket_location, params)
  req.send_request(options)
end

#get_bucket_logging(params = {}) ⇒ Types::GetBucketLoggingOutput

Returns the logging status of a bucket and the permissions users have to view and modify that status. To use GET, you must be the bucket owner.

Examples:

Request syntax with placeholder values


resp = client.get_bucket_logging({
  bucket: "BucketName", # required
})

Response structure


resp.logging_enabled.target_bucket #=> String
resp.logging_enabled.target_grants #=> Array
resp.logging_enabled.target_grants[0].grantee.display_name #=> String
resp.logging_enabled.target_grants[0].grantee.email_address #=> String
resp.logging_enabled.target_grants[0].grantee.id #=> String
resp.logging_enabled.target_grants[0].grantee.type #=> String, one of "CanonicalUser", "AmazonCustomerByEmail", "Group"
resp.logging_enabled.target_grants[0].grantee.uri #=> String
resp.logging_enabled.target_grants[0].permission #=> String, one of "FULL_CONTROL", "READ", "WRITE"
resp.logging_enabled.target_prefix #=> String

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :bucket (required, String)

Returns:

See Also:



2051
2052
2053
2054
# File 'lib/aws-sdk-s3/client.rb', line 2051

def get_bucket_logging(params = {}, options = {})
  req = build_request(:get_bucket_logging, params)
  req.send_request(options)
end

#get_bucket_metrics_configuration(params = {}) ⇒ Types::GetBucketMetricsConfigurationOutput

Gets a metrics configuration (specified by the metrics configuration ID) from the bucket.

Examples:

Request syntax with placeholder values


resp = client.get_bucket_metrics_configuration({
  bucket: "BucketName", # required
  id: "MetricsId", # required
})

Response structure


resp.metrics_configuration.id #=> String
resp.metrics_configuration.filter.prefix #=> String
resp.metrics_configuration.filter.tag.key #=> String
resp.metrics_configuration.filter.tag.value #=> String
resp.metrics_configuration.filter.and.prefix #=> String
resp.metrics_configuration.filter.and.tags #=> Array
resp.metrics_configuration.filter.and.tags[0].key #=> String
resp.metrics_configuration.filter.and.tags[0].value #=> String

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :bucket (required, String)

    The name of the bucket containing the metrics configuration to retrieve.

  • :id (required, String)

    The ID used to identify the metrics configuration.

Returns:

See Also:



2092
2093
2094
2095
# File 'lib/aws-sdk-s3/client.rb', line 2092

def get_bucket_metrics_configuration(params = {}, options = {})
  req = build_request(:get_bucket_metrics_configuration, params)
  req.send_request(options)
end

#get_bucket_notification(params = {}) ⇒ Types::NotificationConfigurationDeprecated

No longer used, see the GetBucketNotificationConfiguration operation.

Examples:

Example: To get notification configuration set on a bucket


# The following example returns notification configuration set on a bucket.

resp = client.get_bucket_notification({
  bucket: "examplebucket", 
})

resp.to_h outputs the following:
{
  queue_configuration: {
    event: "s3:ObjectCreated:Put", 
    events: [
      "s3:ObjectCreated:Put", 
    ], 
    id: "MDQ2OGQ4NDEtOTBmNi00YTM4LTk0NzYtZDIwN2I3NWQ1NjIx", 
    queue: "arn:aws:sqs:us-east-1:acct-id:S3ObjectCreatedEventQueue", 
  }, 
  topic_configuration: {
    event: "s3:ObjectCreated:Copy", 
    events: [
      "s3:ObjectCreated:Copy", 
    ], 
    id: "YTVkMWEzZGUtNTY1NS00ZmE2LWJjYjktMmRlY2QwODFkNTJi", 
    topic: "arn:aws:sns:us-east-1:acct-id:S3ObjectCreatedEventTopic", 
  }, 
}

Example: To get notification configuration set on a bucket


# The following example returns notification configuration set on a bucket.

resp = client.get_bucket_notification({
  bucket: "examplebucket", 
})

resp.to_h outputs the following:
{
  queue_configuration: {
    event: "s3:ObjectCreated:Put", 
    events: [
      "s3:ObjectCreated:Put", 
    ], 
    id: "MDQ2OGQ4NDEtOTBmNi00YTM4LTk0NzYtZDIwN2I3NWQ1NjIx", 
    queue: "arn:aws:sqs:us-east-1:acct-id:S3ObjectCreatedEventQueue", 
  }, 
  topic_configuration: {
    event: "s3:ObjectCreated:Copy", 
    events: [
      "s3:ObjectCreated:Copy", 
    ], 
    id: "YTVkMWEzZGUtNTY1NS00ZmE2LWJjYjktMmRlY2QwODFkNTJi", 
    topic: "arn:aws:sns:us-east-1:acct-id:S3ObjectCreatedEventTopic", 
  }, 
}

Request syntax with placeholder values


resp = client.get_bucket_notification({
  bucket: "BucketName", # required
})

Response structure


resp.topic_configuration.id #=> String
resp.topic_configuration.events #=> Array
resp.topic_configuration.events[0] #=> String, one of "s3:ReducedRedundancyLostObject", "s3:ObjectCreated:*", "s3:ObjectCreated:Put", "s3:ObjectCreated:Post", "s3:ObjectCreated:Copy", "s3:ObjectCreated:CompleteMultipartUpload", "s3:ObjectRemoved:*", "s3:ObjectRemoved:Delete", "s3:ObjectRemoved:DeleteMarkerCreated", "s3:ObjectRestore:Post", "s3:ObjectRestore:Completed"
resp.topic_configuration.event #=> String, one of "s3:ReducedRedundancyLostObject", "s3:ObjectCreated:*", "s3:ObjectCreated:Put", "s3:ObjectCreated:Post", "s3:ObjectCreated:Copy", "s3:ObjectCreated:CompleteMultipartUpload", "s3:ObjectRemoved:*", "s3:ObjectRemoved:Delete", "s3:ObjectRemoved:DeleteMarkerCreated", "s3:ObjectRestore:Post", "s3:ObjectRestore:Completed"
resp.topic_configuration.topic #=> String
resp.queue_configuration.id #=> String
resp.queue_configuration.event #=> String, one of "s3:ReducedRedundancyLostObject", "s3:ObjectCreated:*", "s3:ObjectCreated:Put", "s3:ObjectCreated:Post", "s3:ObjectCreated:Copy", "s3:ObjectCreated:CompleteMultipartUpload", "s3:ObjectRemoved:*", "s3:ObjectRemoved:Delete", "s3:ObjectRemoved:DeleteMarkerCreated", "s3:ObjectRestore:Post", "s3:ObjectRestore:Completed"
resp.queue_configuration.events #=> Array
resp.queue_configuration.events[0] #=> String, one of "s3:ReducedRedundancyLostObject", "s3:ObjectCreated:*", "s3:ObjectCreated:Put", "s3:ObjectCreated:Post", "s3:ObjectCreated:Copy", "s3:ObjectCreated:CompleteMultipartUpload", "s3:ObjectRemoved:*", "s3:ObjectRemoved:Delete", "s3:ObjectRemoved:DeleteMarkerCreated", "s3:ObjectRestore:Post", "s3:ObjectRestore:Completed"
resp.queue_configuration.queue #=> String
resp.cloud_function_configuration.id #=> String
resp.cloud_function_configuration.event #=> String, one of "s3:ReducedRedundancyLostObject", "s3:ObjectCreated:*", "s3:ObjectCreated:Put", "s3:ObjectCreated:Post", "s3:ObjectCreated:Copy", "s3:ObjectCreated:CompleteMultipartUpload", "s3:ObjectRemoved:*", "s3:ObjectRemoved:Delete", "s3:ObjectRemoved:DeleteMarkerCreated", "s3:ObjectRestore:Post", "s3:ObjectRestore:Completed"
resp.cloud_function_configuration.events #=> Array
resp.cloud_function_configuration.events[0] #=> String, one of "s3:ReducedRedundancyLostObject", "s3:ObjectCreated:*", "s3:ObjectCreated:Put", "s3:ObjectCreated:Post", "s3:ObjectCreated:Copy", "s3:ObjectCreated:CompleteMultipartUpload", "s3:ObjectRemoved:*", "s3:ObjectRemoved:Delete", "s3:ObjectRemoved:DeleteMarkerCreated", "s3:ObjectRestore:Post", "s3:ObjectRestore:Completed"
resp.cloud_function_configuration.cloud_function #=> String
resp.cloud_function_configuration.invocation_role #=> String

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :bucket (required, String)

    Name of the bucket to get the notification configuration for.

Returns:

See Also:



2194
2195
2196
2197
# File 'lib/aws-sdk-s3/client.rb', line 2194

def get_bucket_notification(params = {}, options = {})
  req = build_request(:get_bucket_notification, params)
  req.send_request(options)
end

#get_bucket_notification_configuration(params = {}) ⇒ Types::NotificationConfiguration

Returns the notification configuration of a bucket.

Examples:

Request syntax with placeholder values


resp = client.get_bucket_notification_configuration({
  bucket: "BucketName", # required
})

Response structure


resp.topic_configurations #=> Array
resp.topic_configurations[0].id #=> String
resp.topic_configurations[0].topic_arn #=> String
resp.topic_configurations[0].events #=> Array
resp.topic_configurations[0].events[0] #=> String, one of "s3:ReducedRedundancyLostObject", "s3:ObjectCreated:*", "s3:ObjectCreated:Put", "s3:ObjectCreated:Post", "s3:ObjectCreated:Copy", "s3:ObjectCreated:CompleteMultipartUpload", "s3:ObjectRemoved:*", "s3:ObjectRemoved:Delete", "s3:ObjectRemoved:DeleteMarkerCreated", "s3:ObjectRestore:Post", "s3:ObjectRestore:Completed"
resp.topic_configurations[0].filter.key.filter_rules #=> Array
resp.topic_configurations[0].filter.key.filter_rules[0].name #=> String, one of "prefix", "suffix"
resp.topic_configurations[0].filter.key.filter_rules[0].value #=> String
resp.queue_configurations #=> Array
resp.queue_configurations[0].id #=> String
resp.queue_configurations[0].queue_arn #=> String
resp.queue_configurations[0].events #=> Array
resp.queue_configurations[0].events[0] #=> String, one of "s3:ReducedRedundancyLostObject", "s3:ObjectCreated:*", "s3:ObjectCreated:Put", "s3:ObjectCreated:Post", "s3:ObjectCreated:Copy", "s3:ObjectCreated:CompleteMultipartUpload", "s3:ObjectRemoved:*", "s3:ObjectRemoved:Delete", "s3:ObjectRemoved:DeleteMarkerCreated", "s3:ObjectRestore:Post", "s3:ObjectRestore:Completed"
resp.queue_configurations[0].filter.key.filter_rules #=> Array
resp.queue_configurations[0].filter.key.filter_rules[0].name #=> String, one of "prefix", "suffix"
resp.queue_configurations[0].filter.key.filter_rules[0].value #=> String
resp.lambda_function_configurations #=> Array
resp.lambda_function_configurations[0].id #=> String
resp.lambda_function_configurations[0].lambda_function_arn #=> String
resp.lambda_function_configurations[0].events #=> Array
resp.lambda_function_configurations[0].events[0] #=> String, one of "s3:ReducedRedundancyLostObject", "s3:ObjectCreated:*", "s3:ObjectCreated:Put", "s3:ObjectCreated:Post", "s3:ObjectCreated:Copy", "s3:ObjectCreated:CompleteMultipartUpload", "s3:ObjectRemoved:*", "s3:ObjectRemoved:Delete", "s3:ObjectRemoved:DeleteMarkerCreated", "s3:ObjectRestore:Post", "s3:ObjectRestore:Completed"
resp.lambda_function_configurations[0].filter.key.filter_rules #=> Array
resp.lambda_function_configurations[0].filter.key.filter_rules[0].name #=> String, one of "prefix", "suffix"
resp.lambda_function_configurations[0].filter.key.filter_rules[0].value #=> String

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :bucket (required, String)

    Name of the bucket to get the notification configuration for.

Returns:

See Also:



2247
2248
2249
2250
# File 'lib/aws-sdk-s3/client.rb', line 2247

def get_bucket_notification_configuration(params = {}, options = {})
  req = build_request(:get_bucket_notification_configuration, params)
  req.send_request(options)
end

#get_bucket_policy(params = {}) ⇒ Types::GetBucketPolicyOutput

Returns the policy of a specified bucket.

Examples:

Example: To get bucket policy


# The following example returns bucket policy associated with a bucket.

resp = client.get_bucket_policy({
  bucket: "examplebucket", 
})

resp.to_h outputs the following:
{
  policy: "{\"Version\":\"2008-10-17\",\"Id\":\"LogPolicy\",\"Statement\":[{\"Sid\":\"Enables the log delivery group to publish logs to your bucket \",\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"111122223333\"},\"Action\":[\"s3:GetBucketAcl\",\"s3:GetObjectAcl\",\"s3:PutObject\"],\"Resource\":[\"arn:aws:s3:::policytest1/*\",\"arn:aws:s3:::policytest1\"]}]}", 
}

Request syntax with placeholder values


resp = client.get_bucket_policy({
  bucket: "BucketName", # required
})

Response structure


resp.policy #=> String

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :bucket (required, String)

Returns:

See Also:



2288
2289
2290
2291
# File 'lib/aws-sdk-s3/client.rb', line 2288

def get_bucket_policy(params = {}, options = {}, &block)
  req = build_request(:get_bucket_policy, params)
  req.send_request(options, &block)
end

#get_bucket_policy_status(params = {}) ⇒ Types::GetBucketPolicyStatusOutput

Retrieves the policy status for an Amazon S3 bucket, indicating whether the bucket is public.

Examples:

Request syntax with placeholder values


resp = client.get_bucket_policy_status({
  bucket: "BucketName", # required
})

Response structure


resp.policy_status.is_public #=> Boolean

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :bucket (required, String)

    The name of the Amazon S3 bucket whose policy status you want to retrieve.

Returns:

See Also:



2318
2319
2320
2321
# File 'lib/aws-sdk-s3/client.rb', line 2318

def get_bucket_policy_status(params = {}, options = {})
  req = build_request(:get_bucket_policy_status, params)
  req.send_request(options)
end

#get_bucket_replication(params = {}) ⇒ Types::GetBucketReplicationOutput

Returns the replication configuration of a bucket.

<note markdown=“1”> It can take a while to propagate the put or delete a replication configuration to all Amazon S3 systems. Therefore, a get request soon after put or delete can return a wrong result.

</note>

Examples:

Example: To get replication configuration set on a bucket


# The following example returns replication configuration set on a bucket.

resp = client.get_bucket_replication({
  bucket: "examplebucket", 
})

resp.to_h outputs the following:
{
  replication_configuration: {
    role: "arn:aws:iam::acct-id:role/example-role", 
    rules: [
      {
        destination: {
          bucket: "arn:aws:s3:::destination-bucket", 
        }, 
        id: "MWIwNTkwZmItMTE3MS00ZTc3LWJkZDEtNzRmODQwYzc1OTQy", 
        prefix: "Tax", 
        status: "Enabled", 
      }, 
    ], 
  }, 
}

Request syntax with placeholder values


resp = client.get_bucket_replication({
  bucket: "BucketName", # required
})

Response structure


resp.replication_configuration.role #=> String
resp.replication_configuration.rules #=> Array
resp.replication_configuration.rules[0].id #=> String
resp.replication_configuration.rules[0].priority #=> Integer
resp.replication_configuration.rules[0].prefix #=> String
resp.replication_configuration.rules[0].filter.prefix #=> String
resp.replication_configuration.rules[0].filter.tag.key #=> String
resp.replication_configuration.rules[0].filter.tag.value #=> String
resp.replication_configuration.rules[0].filter.and.prefix #=> String
resp.replication_configuration.rules[0].filter.and.tags #=> Array
resp.replication_configuration.rules[0].filter.and.tags[0].key #=> String
resp.replication_configuration.rules[0].filter.and.tags[0].value #=> String
resp.replication_configuration.rules[0].status #=> String, one of "Enabled", "Disabled"
resp.replication_configuration.rules[0].source_selection_criteria.sse_kms_encrypted_objects.status #=> String, one of "Enabled", "Disabled"
resp.replication_configuration.rules[0].destination.bucket #=> String
resp.replication_configuration.rules[0].destination. #=> String
resp.replication_configuration.rules[0].destination.storage_class #=> String, one of "STANDARD", "REDUCED_REDUNDANCY", "STANDARD_IA", "ONEZONE_IA", "INTELLIGENT_TIERING", "GLACIER"
resp.replication_configuration.rules[0].destination.access_control_translation.owner #=> String, one of "Destination"
resp.replication_configuration.rules[0].destination.encryption_configuration.replica_kms_key_id #=> String
resp.replication_configuration.rules[0].delete_marker_replication.status #=> String, one of "Enabled", "Disabled"

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :bucket (required, String)

Returns:

See Also:



2396
2397
2398
2399
# File 'lib/aws-sdk-s3/client.rb', line 2396

def get_bucket_replication(params = {}, options = {})
  req = build_request(:get_bucket_replication, params)
  req.send_request(options)
end

#get_bucket_request_payment(params = {}) ⇒ Types::GetBucketRequestPaymentOutput

Returns the request payment configuration of a bucket.

Examples:

Example: To get bucket versioning configuration


# The following example retrieves bucket versioning configuration.

resp = client.get_bucket_request_payment({
  bucket: "examplebucket", 
})

resp.to_h outputs the following:
{
  payer: "BucketOwner", 
}

Request syntax with placeholder values


resp = client.get_bucket_request_payment({
  bucket: "BucketName", # required
})

Response structure


resp.payer #=> String, one of "Requester", "BucketOwner"

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :bucket (required, String)

Returns:

See Also:



2437
2438
2439
2440
# File 'lib/aws-sdk-s3/client.rb', line 2437

def get_bucket_request_payment(params = {}, options = {})
  req = build_request(:get_bucket_request_payment, params)
  req.send_request(options)
end

#get_bucket_tagging(params = {}) ⇒ Types::GetBucketTaggingOutput

Returns the tag set associated with the bucket.

Examples:

Example: To get tag set associated with a bucket


# The following example returns tag set associated with a bucket

resp = client.get_bucket_tagging({
  bucket: "examplebucket", 
})

resp.to_h outputs the following:
{
  tag_set: [
    {
      key: "key1", 
      value: "value1", 
    }, 
    {
      key: "key2", 
      value: "value2", 
    }, 
  ], 
}

Request syntax with placeholder values


resp = client.get_bucket_tagging({
  bucket: "BucketName", # required
})

Response structure


resp.tag_set #=> Array
resp.tag_set[0].key #=> String
resp.tag_set[0].value #=> String

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :bucket (required, String)

Returns:

See Also:



2489
2490
2491
2492
# File 'lib/aws-sdk-s3/client.rb', line 2489

def get_bucket_tagging(params = {}, options = {})
  req = build_request(:get_bucket_tagging, params)
  req.send_request(options)
end

#get_bucket_versioning(params = {}) ⇒ Types::GetBucketVersioningOutput

Returns the versioning state of a bucket.

Examples:

Example: To get bucket versioning configuration


# The following example retrieves bucket versioning configuration.

resp = client.get_bucket_versioning({
  bucket: "examplebucket", 
})

resp.to_h outputs the following:
{
  mfa_delete: "Disabled", 
  status: "Enabled", 
}

Request syntax with placeholder values


resp = client.get_bucket_versioning({
  bucket: "BucketName", # required
})

Response structure


resp.status #=> String, one of "Enabled", "Suspended"
resp.mfa_delete #=> String, one of "Enabled", "Disabled"

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :bucket (required, String)

Returns:

See Also:



2533
2534
2535
2536
# File 'lib/aws-sdk-s3/client.rb', line 2533

def get_bucket_versioning(params = {}, options = {})
  req = build_request(:get_bucket_versioning, params)
  req.send_request(options)
end

#get_bucket_website(params = {}) ⇒ Types::GetBucketWebsiteOutput

Returns the website configuration for a bucket.

Examples:

Example: To get bucket website configuration


# The following example retrieves website configuration of a bucket.

resp = client.get_bucket_website({
  bucket: "examplebucket", 
})

resp.to_h outputs the following:
{
  error_document: {
    key: "error.html", 
  }, 
  index_document: {
    suffix: "index.html", 
  }, 
}

Request syntax with placeholder values


resp = client.get_bucket_website({
  bucket: "BucketName", # required
})

Response structure


resp.redirect_all_requests_to.host_name #=> String
resp.redirect_all_requests_to.protocol #=> String, one of "http", "https"
resp.index_document.suffix #=> String
resp.error_document.key #=> String
resp.routing_rules #=> Array
resp.routing_rules[0].condition.http_error_code_returned_equals #=> String
resp.routing_rules[0].condition.key_prefix_equals #=> String
resp.routing_rules[0].redirect.host_name #=> String
resp.routing_rules[0].redirect.http_redirect_code #=> String
resp.routing_rules[0].redirect.protocol #=> String, one of "http", "https"
resp.routing_rules[0].redirect.replace_key_prefix_with #=> String
resp.routing_rules[0].redirect.replace_key_with #=> String

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :bucket (required, String)

Returns:

See Also:



2593
2594
2595
2596
# File 'lib/aws-sdk-s3/client.rb', line 2593

def get_bucket_website(params = {}, options = {})
  req = build_request(:get_bucket_website, params)
  req.send_request(options)
end

#get_object(params = {}) ⇒ Types::GetObjectOutput

Retrieves objects from Amazon S3.

Examples:

Example: To retrieve a byte range of an object


# The following example retrieves an object for an S3 bucket. The request specifies the range header to retrieve a
# specific byte range.

resp = client.get_object({
  bucket: "examplebucket", 
  key: "SampleFile.txt", 
  range: "bytes=0-9", 
})

resp.to_h outputs the following:
{
  accept_ranges: "bytes", 
  content_length: 10, 
  content_range: "bytes 0-9/43", 
  content_type: "text/plain", 
  etag: "\"0d94420ffd0bc68cd3d152506b97a9cc\"", 
  last_modified: Time.parse("Thu, 09 Oct 2014 22:57:28 GMT"), 
  metadata: {
  }, 
  version_id: "null", 
}

Example: To retrieve an object


# The following example retrieves an object for an S3 bucket.

resp = client.get_object({
  bucket: "examplebucket", 
  key: "HappyFace.jpg", 
})

resp.to_h outputs the following:
{
  accept_ranges: "bytes", 
  content_length: 3191, 
  content_type: "image/jpeg", 
  etag: "\"6805f2cfc46c0f04559748bb039d69ae\"", 
  last_modified: Time.parse("Thu, 15 Dec 2016 01:19:41 GMT"), 
  metadata: {
  }, 
  tag_count: 2, 
  version_id: "null", 
}

Download an object to disk

# stream object directly to disk
resp = s3.get_object(
  response_target: '/path/to/file',
  bucket: 'bucket-name',
  key: 'object-key')

# you can still access other response data
resp. #=> { ... }
resp.etag #=> "..."

Download object into memory

# omit :response_target to download to a StringIO in memory
resp = s3.get_object(bucket: 'bucket-name', key: 'object-key')

# call #read or #string on the response body
resp.body.read
#=> '...'

Streaming data to a block

# WARNING: yielding data to a block disables retries of networking errors
File.open('/path/to/file', 'wb') do |file|
  s3.get_object(bucket: 'bucket-name', key: 'object-key') do |chunk|
    file.write(chunk)
  end
end

Request syntax with placeholder values


resp = client.get_object({
  bucket: "BucketName", # required
  if_match: "IfMatch",
  if_modified_since: Time.now,
  if_none_match: "IfNoneMatch",
  if_unmodified_since: Time.now,
  key: "ObjectKey", # required
  range: "Range",
  response_cache_control: "ResponseCacheControl",
  response_content_disposition: "ResponseContentDisposition",
  response_content_encoding: "ResponseContentEncoding",
  response_content_language: "ResponseContentLanguage",
  response_content_type: "ResponseContentType",
  response_expires: Time.now,
  version_id: "ObjectVersionId",
  sse_customer_algorithm: "SSECustomerAlgorithm",
  sse_customer_key: "SSECustomerKey",
  sse_customer_key_md5: "SSECustomerKeyMD5",
  request_payer: "requester", # accepts requester
  part_number: 1,
})

Response structure


resp.body #=> IO
resp.delete_marker #=> Boolean
resp.accept_ranges #=> String
resp.expiration #=> String
resp.restore #=> String
resp.last_modified #=> Time
resp.content_length #=> Integer
resp.etag #=> String
resp.missing_meta #=> Integer
resp.version_id #=> String
resp.cache_control #=> String
resp.content_disposition #=> String
resp.content_encoding #=> String
resp.content_language #=> String
resp.content_range #=> String
resp.content_type #=> String
resp.expires #=> Time
resp.expires_string #=> String
resp.website_redirect_location #=> String
resp.server_side_encryption #=> String, one of "AES256", "aws:kms"
resp. #=> Hash
resp.["MetadataKey"] #=> String
resp.sse_customer_algorithm #=> String
resp.sse_customer_key_md5 #=> String
resp.ssekms_key_id #=> String
resp.storage_class #=> String, one of "STANDARD", "REDUCED_REDUNDANCY", "STANDARD_IA", "ONEZONE_IA", "INTELLIGENT_TIERING", "GLACIER"
resp.request_charged #=> String, one of "requester"
resp.replication_status #=> String, one of "COMPLETE", "PENDING", "FAILED", "REPLICA"
resp.parts_count #=> Integer
resp.tag_count #=> Integer
resp.object_lock_mode #=> String, one of "GOVERNANCE", "COMPLIANCE"
resp.object_lock_retain_until_date #=> Time
resp.object_lock_legal_hold_status #=> String, one of "ON", "OFF"

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :response_target (String, IO)

    Where to write response data, file path, or IO object.

  • :bucket (required, String)
  • :if_match (String)

    Return the object only if its entity tag (ETag) is the same as the one specified, otherwise return a 412 (precondition failed).

  • :if_modified_since (Time, DateTime, Date, Integer, String)

    Return the object only if it has been modified since the specified time, otherwise return a 304 (not modified).

  • :if_none_match (String)

    Return the object only if its entity tag (ETag) is different from the one specified, otherwise return a 304 (not modified).

  • :if_unmodified_since (Time, DateTime, Date, Integer, String)

    Return the object only if it has not been modified since the specified time, otherwise return a 412 (precondition failed).

  • :key (required, String)
  • :range (String)

    Downloads the specified range bytes of an object. For more information about the HTTP Range header, go to www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.35.

  • :response_cache_control (String)

    Sets the Cache-Control header of the response.

  • :response_content_disposition (String)

    Sets the Content-Disposition header of the response

  • :response_content_encoding (String)

    Sets the Content-Encoding header of the response.

  • :response_content_language (String)

    Sets the Content-Language header of the response.

  • :response_content_type (String)

    Sets the Content-Type header of the response.

  • :response_expires (Time, DateTime, Date, Integer, String)

    Sets the Expires header of the response.

  • :version_id (String)

    VersionId used to reference a specific version of the object.

  • :sse_customer_algorithm (String)

    Specifies the algorithm to use to when encrypting the object (e.g., AES256).

  • :sse_customer_key (String)

    Specifies the customer-provided encryption key for Amazon S3 to use in encrypting data. This value is used to store the object and then it is discarded; Amazon does not store the encryption key. The key must be appropriate for use with the algorithm specified in the x-amz-server-side​-encryption​-customer-algorithm header.

  • :sse_customer_key_md5 (String)

    Specifies the 128-bit MD5 digest of the encryption key according to RFC 1321. Amazon S3 uses this header for a message integrity check to ensure the encryption key was transmitted without error.

  • :request_payer (String)

    Confirms that the requester knows that she or he will be charged for the request. Bucket owners need not specify this parameter in their requests. Documentation on downloading objects from requester pays buckets can be found at docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html

  • :part_number (Integer)

    Part number of the object being read. This is a positive integer between 1 and 10,000. Effectively performs a ‘ranged’ GET request for the part specified. Useful for downloading just a part of an object.

Returns:

See Also:



2851
2852
2853
2854
# File 'lib/aws-sdk-s3/client.rb', line 2851

def get_object(params = {}, options = {}, &block)
  req = build_request(:get_object, params)
  req.send_request(options, &block)
end

#get_object_acl(params = {}) ⇒ Types::GetObjectAclOutput

Returns the access control list (ACL) of an object.

Examples:

Example: To retrieve object ACL


# The following example retrieves access control list (ACL) of an object.

resp = client.get_object_acl({
  bucket: "examplebucket", 
  key: "HappyFace.jpg", 
})

resp.to_h outputs the following:
{
  grants: [
    {
      grantee: {
        display_name: "owner-display-name", 
        id: "examplee7a2f25102679df27bb0ae12b3f85be6f290b936c4393484be31bebcc", 
        type: "CanonicalUser", 
      }, 
      permission: "WRITE", 
    }, 
    {
      grantee: {
        display_name: "owner-display-name", 
        id: "examplee7a2f25102679df27bb0ae12b3f85be6f290b936c4393484be31bebcc", 
        type: "CanonicalUser", 
      }, 
      permission: "WRITE_ACP", 
    }, 
    {
      grantee: {
        display_name: "owner-display-name", 
        id: "examplee7a2f25102679df27bb0ae12b3f85be6f290b936c4393484be31bebcc", 
        type: "CanonicalUser", 
      }, 
      permission: "READ", 
    }, 
    {
      grantee: {
        display_name: "owner-display-name", 
        id: "852b113eexamplee7a2f25102679df27bb0ae12b3f85be6f290b936c4393484be31bebcc7a2f25102679df27bb0ae12b3f85be6f290b936c4393484be31bebcc", 
        type: "CanonicalUser", 
      }, 
      permission: "READ_ACP", 
    }, 
  ], 
  owner: {
    display_name: "owner-display-name", 
    id: "examplee7a2f25102679df27bb0ae12b3f85be6f290b936c4393484be31bebcc", 
  }, 
}

Request syntax with placeholder values


resp = client.get_object_acl({
  bucket: "BucketName", # required
  key: "ObjectKey", # required
  version_id: "ObjectVersionId",
  request_payer: "requester", # accepts requester
})

Response structure


resp.owner.display_name #=> String
resp.owner.id #=> String
resp.grants #=> Array
resp.grants[0].grantee.display_name #=> String
resp.grants[0].grantee.email_address #=> String
resp.grants[0].grantee.id #=> String
resp.grants[0].grantee.type #=> String, one of "CanonicalUser", "AmazonCustomerByEmail", "Group"
resp.grants[0].grantee.uri #=> String
resp.grants[0].permission #=> String, one of "FULL_CONTROL", "WRITE", "WRITE_ACP", "READ", "READ_ACP"
resp.request_charged #=> String, one of "requester"

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :bucket (required, String)
  • :key (required, String)
  • :version_id (String)

    VersionId used to reference a specific version of the object.

  • :request_payer (String)

    Confirms that the requester knows that she or he will be charged for the request. Bucket owners need not specify this parameter in their requests. Documentation on downloading objects from requester pays buckets can be found at docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html

Returns:

See Also:



2956
2957
2958
2959
# File 'lib/aws-sdk-s3/client.rb', line 2956

def get_object_acl(params = {}, options = {})
  req = build_request(:get_object_acl, params)
  req.send_request(options)
end

Gets an object’s current Legal Hold status.

Examples:

Request syntax with placeholder values


resp = client.get_object_legal_hold({
  bucket: "BucketName", # required
  key: "ObjectKey", # required
  version_id: "ObjectVersionId",
  request_payer: "requester", # accepts requester
})

Response structure


resp.legal_hold.status #=> String, one of "ON", "OFF"

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :bucket (required, String)

    The bucket containing the object whose Legal Hold status you want to retrieve.

  • :key (required, String)

    The key name for the object whose Legal Hold status you want to retrieve.

  • :version_id (String)

    The version ID of the object whose Legal Hold status you want to retrieve.

  • :request_payer (String)

    Confirms that the requester knows that she or he will be charged for the request. Bucket owners need not specify this parameter in their requests. Documentation on downloading objects from requester pays buckets can be found at docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html

Returns:

See Also:



3003
3004
3005
3006
# File 'lib/aws-sdk-s3/client.rb', line 3003

def get_object_legal_hold(params = {}, options = {})
  req = build_request(:get_object_legal_hold, params)
  req.send_request(options)
end

#get_object_lock_configuration(params = {}) ⇒ Types::GetObjectLockConfigurationOutput

Gets the Object Lock configuration for a bucket. The rule specified in the Object Lock configuration will be applied by default to every new object placed in the specified bucket.

Examples:

Request syntax with placeholder values


resp = client.get_object_lock_configuration({
  bucket: "BucketName", # required
})

Response structure


resp.object_lock_configuration.object_lock_enabled #=> String, one of "Enabled"
resp.object_lock_configuration.rule.default_retention.mode #=> String, one of "GOVERNANCE", "COMPLIANCE"
resp.object_lock_configuration.rule.default_retention.days #=> Integer
resp.object_lock_configuration.rule.default_retention.years #=> Integer

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :bucket (required, String)

    The bucket whose Object Lock configuration you want to retrieve.

Returns:

See Also:



3036
3037
3038
3039
# File 'lib/aws-sdk-s3/client.rb', line 3036

def get_object_lock_configuration(params = {}, options = {})
  req = build_request(:get_object_lock_configuration, params)
  req.send_request(options)
end

#get_object_retention(params = {}) ⇒ Types::GetObjectRetentionOutput

Retrieves an object’s retention settings.

Examples:

Request syntax with placeholder values


resp = client.get_object_retention({
  bucket: "BucketName", # required
  key: "ObjectKey", # required
  version_id: "ObjectVersionId",
  request_payer: "requester", # accepts requester
})

Response structure


resp.retention.mode #=> String, one of "GOVERNANCE", "COMPLIANCE"
resp.retention.retain_until_date #=> Time

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :bucket (required, String)

    The bucket containing the object whose retention settings you want to retrieve.

  • :key (required, String)

    The key name for the object whose retention settings you want to retrieve.

  • :version_id (String)

    The version ID for the object whose retention settings you want to retrieve.

  • :request_payer (String)

    Confirms that the requester knows that she or he will be charged for the request. Bucket owners need not specify this parameter in their requests. Documentation on downloading objects from requester pays buckets can be found at docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html

Returns:

See Also:



3084
3085
3086
3087
# File 'lib/aws-sdk-s3/client.rb', line 3084

def get_object_retention(params = {}, options = {})
  req = build_request(:get_object_retention, params)
  req.send_request(options)
end

#get_object_tagging(params = {}) ⇒ Types::GetObjectTaggingOutput

Returns the tag-set of an object.

Examples:

Example: To retrieve tag set of an object


# The following example retrieves tag set of an object.

resp = client.get_object_tagging({
  bucket: "examplebucket", 
  key: "HappyFace.jpg", 
})

resp.to_h outputs the following:
{
  tag_set: [
    {
      key: "Key4", 
      value: "Value4", 
    }, 
    {
      key: "Key3", 
      value: "Value3", 
    }, 
  ], 
  version_id: "null", 
}

Example: To retrieve tag set of a specific object version


# The following example retrieves tag set of an object. The request specifies object version.

resp = client.get_object_tagging({
  bucket: "examplebucket", 
  key: "exampleobject", 
  version_id: "ydlaNkwWm0SfKJR.T1b1fIdPRbldTYRI", 
})

resp.to_h outputs the following:
{
  tag_set: [
    {
      key: "Key1", 
      value: "Value1", 
    }, 
  ], 
  version_id: "ydlaNkwWm0SfKJR.T1b1fIdPRbldTYRI", 
}

Request syntax with placeholder values


resp = client.get_object_tagging({
  bucket: "BucketName", # required
  key: "ObjectKey", # required
  version_id: "ObjectVersionId",
})

Response structure


resp.version_id #=> String
resp.tag_set #=> Array
resp.tag_set[0].key #=> String
resp.tag_set[0].value #=> String

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :bucket (required, String)
  • :key (required, String)
  • :version_id (String)

Returns:

See Also:



3167
3168
3169
3170
# File 'lib/aws-sdk-s3/client.rb', line 3167

def get_object_tagging(params = {}, options = {})
  req = build_request(:get_object_tagging, params)
  req.send_request(options)
end

#get_object_torrent(params = {}) ⇒ Types::GetObjectTorrentOutput

Return torrent files from a bucket.

Examples:

Example: To retrieve torrent files for an object


# The following example retrieves torrent files of an object.

resp = client.get_object_torrent({
  bucket: "examplebucket", 
  key: "HappyFace.jpg", 
})

resp.to_h outputs the following:
{
}

Request syntax with placeholder values


resp = client.get_object_torrent({
  bucket: "BucketName", # required
  key: "ObjectKey", # required
  request_payer: "requester", # accepts requester
})

Response structure


resp.body #=> IO
resp.request_charged #=> String, one of "requester"

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :response_target (String, IO)

    Where to write response data, file path, or IO object.

  • :bucket (required, String)
  • :key (required, String)
  • :request_payer (String)

    Confirms that the requester knows that she or he will be charged for the request. Bucket owners need not specify this parameter in their requests. Documentation on downloading objects from requester pays buckets can be found at docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html

Returns:

See Also:



3224
3225
3226
3227
# File 'lib/aws-sdk-s3/client.rb', line 3224

def get_object_torrent(params = {}, options = {}, &block)
  req = build_request(:get_object_torrent, params)
  req.send_request(options, &block)
end

#get_public_access_block(params = {}) ⇒ Types::GetPublicAccessBlockOutput

Retrieves the ‘PublicAccessBlock` configuration for an Amazon S3 bucket.

Examples:

Request syntax with placeholder values


resp = client.get_public_access_block({
  bucket: "BucketName", # required
})

Response structure


resp.public_access_block_configuration.block_public_acls #=> Boolean
resp.public_access_block_configuration.ignore_public_acls #=> Boolean
resp.public_access_block_configuration.block_public_policy #=> Boolean
resp.public_access_block_configuration.restrict_public_buckets #=> Boolean

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :bucket (required, String)

    The name of the Amazon S3 bucket whose ‘PublicAccessBlock` configuration you want to retrieve.

Returns:

See Also:



3257
3258
3259
3260
# File 'lib/aws-sdk-s3/client.rb', line 3257

def get_public_access_block(params = {}, options = {})
  req = build_request(:get_public_access_block, params)
  req.send_request(options)
end

#head_bucket(params = {}) ⇒ Struct

This operation is useful to determine if a bucket exists and you have permission to access it.

Examples:

Example: To determine if bucket exists


# This operation checks to see if a bucket exists.

resp = client.head_bucket({
  bucket: "acl1", 
})

Request syntax with placeholder values


resp = client.head_bucket({
  bucket: "BucketName", # required
})

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :bucket (required, String)

Returns:

  • (Struct)

    Returns an empty response.

See Also:



3288
3289
3290
3291
# File 'lib/aws-sdk-s3/client.rb', line 3288

def head_bucket(params = {}, options = {})
  req = build_request(:head_bucket, params)
  req.send_request(options)
end

#head_object(params = {}) ⇒ Types::HeadObjectOutput

The HEAD operation retrieves metadata from an object without returning the object itself. This operation is useful if you’re only interested in an object’s metadata. To use HEAD, you must have READ access to the object.

Examples:

Example: To retrieve metadata of an object without returning the object itself


# The following example retrieves an object metadata.

resp = client.head_object({
  bucket: "examplebucket", 
  key: "HappyFace.jpg", 
})

resp.to_h outputs the following:
{
  accept_ranges: "bytes", 
  content_length: 3191, 
  content_type: "image/jpeg", 
  etag: "\"6805f2cfc46c0f04559748bb039d69ae\"", 
  last_modified: Time.parse("Thu, 15 Dec 2016 01:19:41 GMT"), 
  metadata: {
  }, 
  version_id: "null", 
}

Request syntax with placeholder values


resp = client.head_object({
  bucket: "BucketName", # required
  if_match: "IfMatch",
  if_modified_since: Time.now,
  if_none_match: "IfNoneMatch",
  if_unmodified_since: Time.now,
  key: "ObjectKey", # required
  range: "Range",
  version_id: "ObjectVersionId",
  sse_customer_algorithm: "SSECustomerAlgorithm",
  sse_customer_key: "SSECustomerKey",
  sse_customer_key_md5: "SSECustomerKeyMD5",
  request_payer: "requester", # accepts requester
  part_number: 1,
})

Response structure


resp.delete_marker #=> Boolean
resp.accept_ranges #=> String
resp.expiration #=> String
resp.restore #=> String
resp.last_modified #=> Time
resp.content_length #=> Integer
resp.etag #=> String
resp.missing_meta #=> Integer
resp.version_id #=> String
resp.cache_control #=> String
resp.content_disposition #=> String
resp.content_encoding #=> String
resp.content_language #=> String
resp.content_type #=> String
resp.expires #=> Time
resp.expires_string #=> String
resp.website_redirect_location #=> String
resp.server_side_encryption #=> String, one of "AES256", "aws:kms"
resp. #=> Hash
resp.["MetadataKey"] #=> String
resp.sse_customer_algorithm #=> String
resp.sse_customer_key_md5 #=> String
resp.ssekms_key_id #=> String
resp.storage_class #=> String, one of "STANDARD", "REDUCED_REDUNDANCY", "STANDARD_IA", "ONEZONE_IA", "INTELLIGENT_TIERING", "GLACIER"
resp.request_charged #=> String, one of "requester"
resp.replication_status #=> String, one of "COMPLETE", "PENDING", "FAILED", "REPLICA"
resp.parts_count #=> Integer
resp.object_lock_mode #=> String, one of "GOVERNANCE", "COMPLIANCE"
resp.object_lock_retain_until_date #=> Time
resp.object_lock_legal_hold_status #=> String, one of "ON", "OFF"

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :bucket (required, String)
  • :if_match (String)

    Return the object only if its entity tag (ETag) is the same as the one specified, otherwise return a 412 (precondition failed).

  • :if_modified_since (Time, DateTime, Date, Integer, String)

    Return the object only if it has been modified since the specified time, otherwise return a 304 (not modified).

  • :if_none_match (String)

    Return the object only if its entity tag (ETag) is different from the one specified, otherwise return a 304 (not modified).

  • :if_unmodified_since (Time, DateTime, Date, Integer, String)

    Return the object only if it has not been modified since the specified time, otherwise return a 412 (precondition failed).

  • :key (required, String)
  • :range (String)

    Downloads the specified range bytes of an object. For more information about the HTTP Range header, go to www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.35.

  • :version_id (String)

    VersionId used to reference a specific version of the object.

  • :sse_customer_algorithm (String)

    Specifies the algorithm to use to when encrypting the object (e.g., AES256).

  • :sse_customer_key (String)

    Specifies the customer-provided encryption key for Amazon S3 to use in encrypting data. This value is used to store the object and then it is discarded; Amazon does not store the encryption key. The key must be appropriate for use with the algorithm specified in the x-amz-server-side​-encryption​-customer-algorithm header.

  • :sse_customer_key_md5 (String)

    Specifies the 128-bit MD5 digest of the encryption key according to RFC 1321. Amazon S3 uses this header for a message integrity check to ensure the encryption key was transmitted without error.

  • :request_payer (String)

    Confirms that the requester knows that she or he will be charged for the request. Bucket owners need not specify this parameter in their requests. Documentation on downloading objects from requester pays buckets can be found at docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html

  • :part_number (Integer)

    Part number of the object being read. This is a positive integer between 1 and 10,000. Effectively performs a ‘ranged’ HEAD request for the part specified. Useful querying about the size of the part and the number of parts in this object.

Returns:

See Also:



3464
3465
3466
3467
# File 'lib/aws-sdk-s3/client.rb', line 3464

def head_object(params = {}, options = {})
  req = build_request(:head_object, params)
  req.send_request(options)
end

#list_bucket_analytics_configurations(params = {}) ⇒ Types::ListBucketAnalyticsConfigurationsOutput

Lists the analytics configurations for the bucket.

Examples:

Request syntax with placeholder values


resp = client.list_bucket_analytics_configurations({
  bucket: "BucketName", # required
  continuation_token: "Token",
})

Response structure


resp.is_truncated #=> Boolean
resp.continuation_token #=> String
resp.next_continuation_token #=> String
resp.analytics_configuration_list #=> Array
resp.analytics_configuration_list[0].id #=> String
resp.analytics_configuration_list[0].filter.prefix #=> String
resp.analytics_configuration_list[0].filter.tag.key #=> String
resp.analytics_configuration_list[0].filter.tag.value #=> String
resp.analytics_configuration_list[0].filter.and.prefix #=> String
resp.analytics_configuration_list[0].filter.and.tags #=> Array
resp.analytics_configuration_list[0].filter.and.tags[0].key #=> String
resp.analytics_configuration_list[0].filter.and.tags[0].value #=> String
resp.analytics_configuration_list[0].storage_class_analysis.data_export.output_schema_version #=> String, one of "V_1"
resp.analytics_configuration_list[0].storage_class_analysis.data_export.destination.s3_bucket_destination.format #=> String, one of "CSV"
resp.analytics_configuration_list[0].storage_class_analysis.data_export.destination.s3_bucket_destination. #=> String
resp.analytics_configuration_list[0].storage_class_analysis.data_export.destination.s3_bucket_destination.bucket #=> String
resp.analytics_configuration_list[0].storage_class_analysis.data_export.destination.s3_bucket_destination.prefix #=> String

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :bucket (required, String)

    The name of the bucket from which analytics configurations are retrieved.

  • :continuation_token (String)

    The ContinuationToken that represents a placeholder from where this request should begin.

Returns:

See Also:



3517
3518
3519
3520
# File 'lib/aws-sdk-s3/client.rb', line 3517

def list_bucket_analytics_configurations(params = {}, options = {})
  req = build_request(:list_bucket_analytics_configurations, params)
  req.send_request(options)
end

#list_bucket_inventory_configurations(params = {}) ⇒ Types::ListBucketInventoryConfigurationsOutput

Returns a list of inventory configurations for the bucket.

Examples:

Request syntax with placeholder values


resp = client.list_bucket_inventory_configurations({
  bucket: "BucketName", # required
  continuation_token: "Token",
})

Response structure


resp.continuation_token #=> String
resp.inventory_configuration_list #=> Array
resp.inventory_configuration_list[0].destination.s3_bucket_destination. #=> String
resp.inventory_configuration_list[0].destination.s3_bucket_destination.bucket #=> String
resp.inventory_configuration_list[0].destination.s3_bucket_destination.format #=> String, one of "CSV", "ORC", "Parquet"
resp.inventory_configuration_list[0].destination.s3_bucket_destination.prefix #=> String
resp.inventory_configuration_list[0].destination.s3_bucket_destination.encryption.ssekms.key_id #=> String
resp.inventory_configuration_list[0].is_enabled #=> Boolean
resp.inventory_configuration_list[0].filter.prefix #=> String
resp.inventory_configuration_list[0].id #=> String
resp.inventory_configuration_list[0].included_object_versions #=> String, one of "All", "Current"
resp.inventory_configuration_list[0].optional_fields #=> Array
resp.inventory_configuration_list[0].optional_fields[0] #=> String, one of "Size", "LastModifiedDate", "StorageClass", "ETag", "IsMultipartUploaded", "ReplicationStatus", "EncryptionStatus", "ObjectLockRetainUntilDate", "ObjectLockMode", "ObjectLockLegalHoldStatus"
resp.inventory_configuration_list[0].schedule.frequency #=> String, one of "Daily", "Weekly"
resp.is_truncated #=> Boolean
resp.next_continuation_token #=> String

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :bucket (required, String)

    The name of the bucket containing the inventory configurations to retrieve.

  • :continuation_token (String)

    The marker used to continue an inventory configuration listing that has been truncated. Use the NextContinuationToken from a previously truncated list response to continue the listing. The continuation token is an opaque value that Amazon S3 understands.

Returns:

See Also:



3571
3572
3573
3574
# File 'lib/aws-sdk-s3/client.rb', line 3571

def list_bucket_inventory_configurations(params = {}, options = {})
  req = build_request(:list_bucket_inventory_configurations, params)
  req.send_request(options)
end

#list_bucket_metrics_configurations(params = {}) ⇒ Types::ListBucketMetricsConfigurationsOutput

Lists the metrics configurations for the bucket.

Examples:

Request syntax with placeholder values


resp = client.list_bucket_metrics_configurations({
  bucket: "BucketName", # required
  continuation_token: "Token",
})

Response structure


resp.is_truncated #=> Boolean
resp.continuation_token #=> String
resp.next_continuation_token #=> String
resp.metrics_configuration_list #=> Array
resp.metrics_configuration_list[0].id #=> String
resp.metrics_configuration_list[0].filter.prefix #=> String
resp.metrics_configuration_list[0].filter.tag.key #=> String
resp.metrics_configuration_list[0].filter.tag.value #=> String
resp.metrics_configuration_list[0].filter.and.prefix #=> String
resp.metrics_configuration_list[0].filter.and.tags #=> Array
resp.metrics_configuration_list[0].filter.and.tags[0].key #=> String
resp.metrics_configuration_list[0].filter.and.tags[0].value #=> String

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :bucket (required, String)

    The name of the bucket containing the metrics configurations to retrieve.

  • :continuation_token (String)

    The marker that is used to continue a metrics configuration listing that has been truncated. Use the NextContinuationToken from a previously truncated list response to continue the listing. The continuation token is an opaque value that Amazon S3 understands.

Returns:

See Also:



3621
3622
3623
3624
# File 'lib/aws-sdk-s3/client.rb', line 3621

def list_bucket_metrics_configurations(params = {}, options = {})
  req = build_request(:list_bucket_metrics_configurations, params)
  req.send_request(options)
end

#list_buckets(params = {}) ⇒ Types::ListBucketsOutput

Returns a list of all buckets owned by the authenticated sender of the request.

Examples:

Example: To list object versions


# The following example return versions of an object with specific key name prefix. The request limits the number of items
# returned to two. If there are are more than two object version, S3 returns NextToken in the response. You can specify
# this token value in your next request to fetch next set of object versions.

resp = client.list_buckets({
})

resp.to_h outputs the following:
{
  buckets: [
    {
      creation_date: Time.parse("2012-02-15T21: 03: 02.000Z"), 
      name: "examplebucket", 
    }, 
    {
      creation_date: Time.parse("2011-07-24T19: 33: 50.000Z"), 
      name: "examplebucket2", 
    }, 
    {
      creation_date: Time.parse("2010-12-17T00: 56: 49.000Z"), 
      name: "examplebucket3", 
    }, 
  ], 
  owner: {
    display_name: "own-display-name", 
    id: "examplee7a2f25102679df27bb0ae12b3f85be6f290b936c4393484be31", 
  }, 
}

Response structure


resp.buckets #=> Array
resp.buckets[0].name #=> String
resp.buckets[0].creation_date #=> Time
resp.owner.display_name #=> String
resp.owner.id #=> String

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Returns:

See Also:



3678
3679
3680
3681
# File 'lib/aws-sdk-s3/client.rb', line 3678

def list_buckets(params = {}, options = {})
  req = build_request(:list_buckets, params)
  req.send_request(options)
end

#list_multipart_uploads(params = {}) ⇒ Types::ListMultipartUploadsOutput

This operation lists in-progress multipart uploads.

Examples:

Example: To list in-progress multipart uploads on a bucket


# The following example lists in-progress multipart uploads on a specific bucket.

resp = client.list_multipart_uploads({
  bucket: "examplebucket", 
})

resp.to_h outputs the following:
{
  uploads: [
    {
      initiated: Time.parse("2014-05-01T05:40:58.000Z"), 
      initiator: {
        display_name: "display-name", 
        id: "examplee7a2f25102679df27bb0ae12b3f85be6f290b936c4393484be31bebcc", 
      }, 
      key: "JavaFile", 
      owner: {
        display_name: "display-name", 
        id: "examplee7a2f25102679df27bb0ae12b3f85be6f290b936c4393484be31bebcc", 
      }, 
      storage_class: "STANDARD", 
      upload_id: "examplelUa.CInXklLQtSMJITdUnoZ1Y5GACB5UckOtspm5zbDMCkPF_qkfZzMiFZ6dksmcnqxJyIBvQMG9X9Q--", 
    }, 
    {
      initiated: Time.parse("2014-05-01T05:41:27.000Z"), 
      initiator: {
        display_name: "display-name", 
        id: "examplee7a2f25102679df27bb0ae12b3f85be6f290b936c4393484be31bebcc", 
      }, 
      key: "JavaFile", 
      owner: {
        display_name: "display-name", 
        id: "examplee7a2f25102679df27bb0ae12b3f85be6f290b936c4393484be31bebcc", 
      }, 
      storage_class: "STANDARD", 
      upload_id: "examplelo91lv1iwvWpvCiJWugw2xXLPAD7Z8cJyX9.WiIRgNrdG6Ldsn.9FtS63TCl1Uf5faTB.1U5Ckcbmdw--", 
    }, 
  ], 
}

Example: List next set of multipart uploads when previous result is truncated


# The following example specifies the upload-id-marker and key-marker from previous truncated response to retrieve next
# setup of multipart uploads.

resp = client.list_multipart_uploads({
  bucket: "examplebucket", 
  key_marker: "nextkeyfrompreviousresponse", 
  max_uploads: 2, 
  upload_id_marker: "valuefrompreviousresponse", 
})

resp.to_h outputs the following:
{
  bucket: "acl1", 
  is_truncated: true, 
  key_marker: "", 
  max_uploads: 2, 
  next_key_marker: "someobjectkey", 
  next_upload_id_marker: "examplelo91lv1iwvWpvCiJWugw2xXLPAD7Z8cJyX9.WiIRgNrdG6Ldsn.9FtS63TCl1Uf5faTB.1U5Ckcbmdw--", 
  upload_id_marker: "", 
  uploads: [
    {
      initiated: Time.parse("2014-05-01T05:40:58.000Z"), 
      initiator: {
        display_name: "ownder-display-name", 
        id: "examplee7a2f25102679df27bb0ae12b3f85be6f290b936c4393484be31bebcc", 
      }, 
      key: "JavaFile", 
      owner: {
        display_name: "mohanataws", 
        id: "852b113e7a2f25102679df27bb0ae12b3f85be6f290b936c4393484be31bebcc", 
      }, 
      storage_class: "STANDARD", 
      upload_id: "gZ30jIqlUa.CInXklLQtSMJITdUnoZ1Y5GACB5UckOtspm5zbDMCkPF_qkfZzMiFZ6dksmcnqxJyIBvQMG9X9Q--", 
    }, 
    {
      initiated: Time.parse("2014-05-01T05:41:27.000Z"), 
      initiator: {
        display_name: "ownder-display-name", 
        id: "examplee7a2f25102679df27bb0ae12b3f85be6f290b936c4393484be31bebcc", 
      }, 
      key: "JavaFile", 
      owner: {
        display_name: "ownder-display-name", 
        id: "examplee7a2f25102679df27bb0ae12b3f85be6f290b936c4393484be31bebcc", 
      }, 
      storage_class: "STANDARD", 
      upload_id: "b7tZSqIlo91lv1iwvWpvCiJWugw2xXLPAD7Z8cJyX9.WiIRgNrdG6Ldsn.9FtS63TCl1Uf5faTB.1U5Ckcbmdw--", 
    }, 
  ], 
}

Request syntax with placeholder values


resp = client.list_multipart_uploads({
  bucket: "BucketName", # required
  delimiter: "Delimiter",
  encoding_type: "url", # accepts url
  key_marker: "KeyMarker",
  max_uploads: 1,
  prefix: "Prefix",
  upload_id_marker: "UploadIdMarker",
})

Response structure


resp.bucket #=> String
resp.key_marker #=> String
resp.upload_id_marker #=> String
resp.next_key_marker #=> String
resp.prefix #=> String
resp.delimiter #=> String
resp.next_upload_id_marker #=> String
resp.max_uploads #=> Integer
resp.is_truncated #=> Boolean
resp.uploads #=> Array
resp.uploads[0].upload_id #=> String
resp.uploads[0].key #=> String
resp.uploads[0].initiated #=> Time
resp.uploads[0].storage_class #=> String, one of "STANDARD", "REDUCED_REDUNDANCY", "STANDARD_IA", "ONEZONE_IA", "INTELLIGENT_TIERING", "GLACIER"
resp.uploads[0].owner.display_name #=> String
resp.uploads[0].owner.id #=> String
resp.uploads[0].initiator.id #=> String
resp.uploads[0].initiator.display_name #=> String
resp.common_prefixes #=> Array
resp.common_prefixes[0].prefix #=> String
resp.encoding_type #=> String, one of "url"

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :bucket (required, String)
  • :delimiter (String)

    Character you use to group keys.

  • :encoding_type (String)

    Requests Amazon S3 to encode the object keys in the response and specifies the encoding method to use. An object key may contain any Unicode character; however, XML 1.0 parser cannot parse some characters, such as characters with an ASCII value from 0 to 10. For characters that are not supported in XML 1.0, you can add this parameter to request that Amazon S3 encode the keys in the response.

  • :key_marker (String)

    Together with upload-id-marker, this parameter specifies the multipart upload after which listing should begin.

  • :max_uploads (Integer)

    Sets the maximum number of multipart uploads, from 1 to 1,000, to return in the response body. 1,000 is the maximum number of uploads that can be returned in a response.

  • :prefix (String)

    Lists in-progress uploads only for those keys that begin with the specified prefix.

  • :upload_id_marker (String)

    Together with key-marker, specifies the multipart upload after which listing should begin. If key-marker is not specified, the upload-id-marker parameter is ignored.

Returns:

See Also:



3867
3868
3869
3870
# File 'lib/aws-sdk-s3/client.rb', line 3867

def list_multipart_uploads(params = {}, options = {})
  req = build_request(:list_multipart_uploads, params)
  req.send_request(options)
end

#list_object_versions(params = {}) ⇒ Types::ListObjectVersionsOutput

Returns metadata about all of the versions of objects in a bucket.

Examples:

Example: To list object versions


# The following example return versions of an object with specific key name prefix. The request limits the number of items
# returned to two. If there are are more than two object version, S3 returns NextToken in the response. You can specify
# this token value in your next request to fetch next set of object versions.

resp = client.list_object_versions({
  bucket: "examplebucket", 
  prefix: "HappyFace.jpg", 
})

resp.to_h outputs the following:
{
  versions: [
    {
      etag: "\"6805f2cfc46c0f04559748bb039d69ae\"", 
      is_latest: true, 
      key: "HappyFace.jpg", 
      last_modified: Time.parse("2016-12-15T01:19:41.000Z"), 
      owner: {
        display_name: "owner-display-name", 
        id: "examplee7a2f25102679df27bb0ae12b3f85be6f290b936c4393484be31bebcc", 
      }, 
      size: 3191, 
      storage_class: "STANDARD", 
      version_id: "null", 
    }, 
    {
      etag: "\"6805f2cfc46c0f04559748bb039d69ae\"", 
      is_latest: false, 
      key: "HappyFace.jpg", 
      last_modified: Time.parse("2016-12-13T00:58:26.000Z"), 
      owner: {
        display_name: "owner-display-name", 
        id: "examplee7a2f25102679df27bb0ae12b3f85be6f290b936c4393484be31bebcc", 
      }, 
      size: 3191, 
      storage_class: "STANDARD", 
      version_id: "PHtexPGjH2y.zBgT8LmB7wwLI2mpbz.k", 
    }, 
  ], 
}

Request syntax with placeholder values


resp = client.list_object_versions({
  bucket: "BucketName", # required
  delimiter: "Delimiter",
  encoding_type: "url", # accepts url
  key_marker: "KeyMarker",
  max_keys: 1,
  prefix: "Prefix",
  version_id_marker: "VersionIdMarker",
})

Response structure


resp.is_truncated #=> Boolean
resp.key_marker #=> String
resp.version_id_marker #=> String
resp.next_key_marker #=> String
resp.next_version_id_marker #=> String
resp.versions #=> Array
resp.versions[0].etag #=> String
resp.versions[0].size #=> Integer
resp.versions[0].storage_class #=> String, one of "STANDARD"
resp.versions[0].key #=> String
resp.versions[0].version_id #=> String
resp.versions[0].is_latest #=> Boolean
resp.versions[0].last_modified #=> Time
resp.versions[0].owner.display_name #=> String
resp.versions[0].owner.id #=> String
resp.delete_markers #=> Array
resp.delete_markers[0].owner.display_name #=> String
resp.delete_markers[0].owner.id #=> String
resp.delete_markers[0].key #=> String
resp.delete_markers[0].version_id #=> String
resp.delete_markers[0].is_latest #=> Boolean
resp.delete_markers[0].last_modified #=> Time
resp.name #=> String
resp.prefix #=> String
resp.delimiter #=> String
resp.max_keys #=> Integer
resp.common_prefixes #=> Array
resp.common_prefixes[0].prefix #=> String
resp.encoding_type #=> String, one of "url"

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :bucket (required, String)
  • :delimiter (String)

    A delimiter is a character you use to group keys.

  • :encoding_type (String)

    Requests Amazon S3 to encode the object keys in the response and specifies the encoding method to use. An object key may contain any Unicode character; however, XML 1.0 parser cannot parse some characters, such as characters with an ASCII value from 0 to 10. For characters that are not supported in XML 1.0, you can add this parameter to request that Amazon S3 encode the keys in the response.

  • :key_marker (String)

    Specifies the key to start with when listing objects in a bucket.

  • :max_keys (Integer)

    Sets the maximum number of keys returned in the response. The response might contain fewer keys but will never contain more.

  • :prefix (String)

    Limits the response to keys that begin with the specified prefix.

  • :version_id_marker (String)

    Specifies the object version you want to start listing from.

Returns:

See Also:



4008
4009
4010
4011
# File 'lib/aws-sdk-s3/client.rb', line 4008

def list_object_versions(params = {}, options = {})
  req = build_request(:list_object_versions, params)
  req.send_request(options)
end

#list_objects(params = {}) ⇒ Types::ListObjectsOutput

Returns some or all (up to 1000) of the objects in a bucket. You can use the request parameters as selection criteria to return a subset of the objects in a bucket.

Examples:

Example: To list objects in a bucket


# The following example list two objects in a bucket.

resp = client.list_objects({
  bucket: "examplebucket", 
  max_keys: 2, 
})

resp.to_h outputs the following:
{
  contents: [
    {
      etag: "\"70ee1738b6b21e2c8a43f3a5ab0eee71\"", 
      key: "example1.jpg", 
      last_modified: Time.parse("2014-11-21T19:40:05.000Z"), 
      owner: {
        display_name: "myname", 
        id: "12345example25102679df27bb0ae12b3f85be6f290b936c4393484be31bebcc", 
      }, 
      size: 11, 
      storage_class: "STANDARD", 
    }, 
    {
      etag: "\"9c8af9a76df052144598c115ef33e511\"", 
      key: "example2.jpg", 
      last_modified: Time.parse("2013-11-15T01:10:49.000Z"), 
      owner: {
        display_name: "myname", 
        id: "12345example25102679df27bb0ae12b3f85be6f290b936c4393484be31bebcc", 
      }, 
      size: 713193, 
      storage_class: "STANDARD", 
    }, 
  ], 
  next_marker: "eyJNYXJrZXIiOiBudWxsLCAiYm90b190cnVuY2F0ZV9hbW91bnQiOiAyfQ==", 
}

Request syntax with placeholder values


resp = client.list_objects({
  bucket: "BucketName", # required
  delimiter: "Delimiter",
  encoding_type: "url", # accepts url
  marker: "Marker",
  max_keys: 1,
  prefix: "Prefix",
  request_payer: "requester", # accepts requester
})

Response structure


resp.is_truncated #=> Boolean
resp.marker #=> String
resp.next_marker #=> String
resp.contents #=> Array
resp.contents[0].key #=> String
resp.contents[0].last_modified #=> Time
resp.contents[0].etag #=> String
resp.contents[0].size #=> Integer
resp.contents[0].storage_class #=> String, one of "STANDARD", "REDUCED_REDUNDANCY", "GLACIER", "STANDARD_IA", "ONEZONE_IA", "INTELLIGENT_TIERING"
resp.contents[0].owner.display_name #=> String
resp.contents[0].owner.id #=> String
resp.name #=> String
resp.prefix #=> String
resp.delimiter #=> String
resp.max_keys #=> Integer
resp.common_prefixes #=> Array
resp.common_prefixes[0].prefix #=> String
resp.encoding_type #=> String, one of "url"

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :bucket (required, String)
  • :delimiter (String)

    A delimiter is a character you use to group keys.

  • :encoding_type (String)

    Requests Amazon S3 to encode the object keys in the response and specifies the encoding method to use. An object key may contain any Unicode character; however, XML 1.0 parser cannot parse some characters, such as characters with an ASCII value from 0 to 10. For characters that are not supported in XML 1.0, you can add this parameter to request that Amazon S3 encode the keys in the response.

  • :marker (String)

    Specifies the key to start with when listing objects in a bucket.

  • :max_keys (Integer)

    Sets the maximum number of keys returned in the response. The response might contain fewer keys but will never contain more.

  • :prefix (String)

    Limits the response to keys that begin with the specified prefix.

  • :request_payer (String)

    Confirms that the requester knows that she or he will be charged for the list objects request. Bucket owners need not specify this parameter in their requests.

Returns:

See Also:



4134
4135
4136
4137
# File 'lib/aws-sdk-s3/client.rb', line 4134

def list_objects(params = {}, options = {})
  req = build_request(:list_objects, params)
  req.send_request(options)
end

#list_objects_v2(params = {}) ⇒ Types::ListObjectsV2Output

Returns some or all (up to 1000) of the objects in a bucket. You can use the request parameters as selection criteria to return a subset of the objects in a bucket. Note: ListObjectsV2 is the revised List Objects API and we recommend you use this revised API for new application development.

Examples:

Example: To get object list


# The following example retrieves object list. The request specifies max keys to limit response to include only 2 object
# keys. 

resp = client.list_objects_v2({
  bucket: "examplebucket", 
  max_keys: 2, 
})

resp.to_h outputs the following:
{
  contents: [
    {
      etag: "\"70ee1738b6b21e2c8a43f3a5ab0eee71\"", 
      key: "happyface.jpg", 
      last_modified: Time.parse("2014-11-21T19:40:05.000Z"), 
      size: 11, 
      storage_class: "STANDARD", 
    }, 
    {
      etag: "\"becf17f89c30367a9a44495d62ed521a-1\"", 
      key: "test.jpg", 
      last_modified: Time.parse("2014-05-02T04:51:50.000Z"), 
      size: 4192256, 
      storage_class: "STANDARD", 
    }, 
  ], 
  is_truncated: true, 
  key_count: 2, 
  max_keys: 2, 
  name: "examplebucket", 
  next_continuation_token: "1w41l63U0xa8q7smH50vCxyTQqdxo69O3EmK28Bi5PcROI4wI/EyIJg==", 
  prefix: "", 
}

Request syntax with placeholder values


resp = client.list_objects_v2({
  bucket: "BucketName", # required
  delimiter: "Delimiter",
  encoding_type: "url", # accepts url
  max_keys: 1,
  prefix: "Prefix",
  continuation_token: "Token",
  fetch_owner: false,
  start_after: "StartAfter",
  request_payer: "requester", # accepts requester
})

Response structure


resp.is_truncated #=> Boolean
resp.contents #=> Array
resp.contents[0].key #=> String
resp.contents[0].last_modified #=> Time
resp.contents[0].etag #=> String
resp.contents[0].size #=> Integer
resp.contents[0].storage_class #=> String, one of "STANDARD", "REDUCED_REDUNDANCY", "GLACIER", "STANDARD_IA", "ONEZONE_IA", "INTELLIGENT_TIERING"
resp.contents[0].owner.display_name #=> String
resp.contents[0].owner.id #=> String
resp.name #=> String
resp.prefix #=> String
resp.delimiter #=> String
resp.max_keys #=> Integer
resp.common_prefixes #=> Array
resp.common_prefixes[0].prefix #=> String
resp.encoding_type #=> String, one of "url"
resp.key_count #=> Integer
resp.continuation_token #=> String
resp.next_continuation_token #=> String
resp.start_after #=> String

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :bucket (required, String)

    Name of the bucket to list.

  • :delimiter (String)

    A delimiter is a character you use to group keys.

  • :encoding_type (String)

    Encoding type used by Amazon S3 to encode object keys in the response.

  • :max_keys (Integer)

    Sets the maximum number of keys returned in the response. The response might contain fewer keys but will never contain more.

  • :prefix (String)

    Limits the response to keys that begin with the specified prefix.

  • :continuation_token (String)

    ContinuationToken indicates Amazon S3 that the list is being continued on this bucket with a token. ContinuationToken is obfuscated and is not a real key

  • :fetch_owner (Boolean)

    The owner field is not present in listV2 by default, if you want to return owner field with each key in the result then set the fetch owner field to true

  • :start_after (String)

    StartAfter is where you want Amazon S3 to start listing from. Amazon S3 starts listing after this specified key. StartAfter can be any key in the bucket

  • :request_payer (String)

    Confirms that the requester knows that she or he will be charged for the list objects request in V2 style. Bucket owners need not specify this parameter in their requests.

Returns:

See Also:



4274
4275
4276
4277
# File 'lib/aws-sdk-s3/client.rb', line 4274

def list_objects_v2(params = {}, options = {})
  req = build_request(:list_objects_v2, params)
  req.send_request(options)
end

#list_parts(params = {}) ⇒ Types::ListPartsOutput

Lists the parts that have been uploaded for a specific multipart upload.

Examples:

Example: To list parts of a multipart upload.


# The following example lists parts uploaded for a specific multipart upload.

resp = client.list_parts({
  bucket: "examplebucket", 
  key: "bigobject", 
  upload_id: "example7YPBOJuoFiQ9cz4P3Pe6FIZwO4f7wN93uHsNBEw97pl5eNwzExg0LAT2dUN91cOmrEQHDsP3WA60CEg--", 
})

resp.to_h outputs the following:
{
  initiator: {
    display_name: "owner-display-name", 
    id: "examplee7a2f25102679df27bb0ae12b3f85be6f290b936c4393484be31bebcc", 
  }, 
  owner: {
    display_name: "owner-display-name", 
    id: "examplee7a2f25102679df27bb0ae12b3f85be6f290b936c4393484be31bebcc", 
  }, 
  parts: [
    {
      etag: "\"d8c2eafd90c266e19ab9dcacc479f8af\"", 
      last_modified: Time.parse("2016-12-16T00:11:42.000Z"), 
      part_number: 1, 
      size: 26246026, 
    }, 
    {
      etag: "\"d8c2eafd90c266e19ab9dcacc479f8af\"", 
      last_modified: Time.parse("2016-12-16T00:15:01.000Z"), 
      part_number: 2, 
      size: 26246026, 
    }, 
  ], 
  storage_class: "STANDARD", 
}

Request syntax with placeholder values


resp = client.list_parts({
  bucket: "BucketName", # required
  key: "ObjectKey", # required
  max_parts: 1,
  part_number_marker: 1,
  upload_id: "MultipartUploadId", # required
  request_payer: "requester", # accepts requester
})

Response structure


resp.abort_date #=> Time
resp.abort_rule_id #=> String
resp.bucket #=> String
resp.key #=> String
resp.upload_id #=> String
resp.part_number_marker #=> Integer
resp.next_part_number_marker #=> Integer
resp.max_parts #=> Integer
resp.is_truncated #=> Boolean
resp.parts #=> Array
resp.parts[0].part_number #=> Integer
resp.parts[0].last_modified #=> Time
resp.parts[0].etag #=> String
resp.parts[0].size #=> Integer
resp.initiator.id #=> String
resp.initiator.display_name #=> String
resp.owner.display_name #=> String
resp.owner.id #=> String
resp.storage_class #=> String, one of "STANDARD", "REDUCED_REDUNDANCY", "STANDARD_IA", "ONEZONE_IA", "INTELLIGENT_TIERING", "GLACIER"
resp.request_charged #=> String, one of "requester"

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :bucket (required, String)
  • :key (required, String)
  • :max_parts (Integer)

    Sets the maximum number of parts to return.

  • :part_number_marker (Integer)

    Specifies the part after which listing should begin. Only parts with higher part numbers will be listed.

  • :upload_id (required, String)

    Upload ID identifying the multipart upload whose parts are being listed.

  • :request_payer (String)

    Confirms that the requester knows that she or he will be charged for the request. Bucket owners need not specify this parameter in their requests. Documentation on downloading objects from requester pays buckets can be found at docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html

Returns:

See Also:



4397
4398
4399
4400
# File 'lib/aws-sdk-s3/client.rb', line 4397

def list_parts(params = {}, options = {})
  req = build_request(:list_parts, params)
  req.send_request(options)
end

#put_bucket_accelerate_configuration(params = {}) ⇒ Struct

Sets the accelerate configuration of an existing bucket.

Examples:

Request syntax with placeholder values


resp = client.put_bucket_accelerate_configuration({
  bucket: "BucketName", # required
  accelerate_configuration: { # required
    status: "Enabled", # accepts Enabled, Suspended
  },
})

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :bucket (required, String)

    Name of the bucket for which the accelerate configuration is set.

  • :accelerate_configuration (required, Types::AccelerateConfiguration)

    Specifies the Accelerate Configuration you want to set for the bucket.

Returns:

  • (Struct)

    Returns an empty response.

See Also:



4425
4426
4427
4428
# File 'lib/aws-sdk-s3/client.rb', line 4425

def put_bucket_accelerate_configuration(params = {}, options = {})
  req = build_request(:put_bucket_accelerate_configuration, params)
  req.send_request(options)
end

#put_bucket_acl(params = {}) ⇒ Struct

Sets the permissions on a bucket using access control lists (ACL).

Examples:

Example: Put bucket acl


# The following example replaces existing ACL on a bucket. The ACL grants the bucket owner (specified using the owner ID)
# and write permission to the LogDelivery group. Because this is a replace operation, you must specify all the grants in
# your request. To incrementally add or remove ACL grants, you might use the console.

resp = client.put_bucket_acl({
  bucket: "examplebucket", 
  grant_full_control: "id=examplee7a2f25102679df27bb0ae12b3f85be6f290b936c4393484", 
  grant_write: "uri=http://acs.amazonaws.com/groups/s3/LogDelivery", 
})

Request syntax with placeholder values


resp = client.put_bucket_acl({
  acl: "private", # accepts private, public-read, public-read-write, authenticated-read
  access_control_policy: {
    grants: [
      {
        grantee: {
          display_name: "DisplayName",
          email_address: "EmailAddress",
          id: "ID",
          type: "CanonicalUser", # required, accepts CanonicalUser, AmazonCustomerByEmail, Group
          uri: "URI",
        },
        permission: "FULL_CONTROL", # accepts FULL_CONTROL, WRITE, WRITE_ACP, READ, READ_ACP
      },
    ],
    owner: {
      display_name: "DisplayName",
      id: "ID",
    },
  },
  bucket: "BucketName", # required
  content_md5: "ContentMD5",
  grant_full_control: "GrantFullControl",
  grant_read: "GrantRead",
  grant_read_acp: "GrantReadACP",
  grant_write: "GrantWrite",
  grant_write_acp: "GrantWriteACP",
})

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :acl (String)

    The canned ACL to apply to the bucket.

  • :access_control_policy (Types::AccessControlPolicy)
  • :bucket (required, String)
  • :content_md5 (String)
  • :grant_full_control (String)

    Allows grantee the read, write, read ACP, and write ACP permissions on the bucket.

  • :grant_read (String)

    Allows grantee to list the objects in the bucket.

  • :grant_read_acp (String)

    Allows grantee to read the bucket ACL.

  • :grant_write (String)

    Allows grantee to create, overwrite, and delete any object in the bucket.

  • :grant_write_acp (String)

    Allows grantee to write the ACL for the applicable bucket.

Returns:

  • (Struct)

    Returns an empty response.

See Also:



4508
4509
4510
4511
# File 'lib/aws-sdk-s3/client.rb', line 4508

def put_bucket_acl(params = {}, options = {})
  req = build_request(:put_bucket_acl, params)
  req.send_request(options)
end

#put_bucket_analytics_configuration(params = {}) ⇒ Struct

Sets an analytics configuration for the bucket (specified by the analytics configuration ID).

Examples:

Request syntax with placeholder values


resp = client.put_bucket_analytics_configuration({
  bucket: "BucketName", # required
  id: "AnalyticsId", # required
  analytics_configuration: { # required
    id: "AnalyticsId", # required
    filter: {
      prefix: "Prefix",
      tag: {
        key: "ObjectKey", # required
        value: "Value", # required
      },
      and: {
        prefix: "Prefix",
        tags: [
          {
            key: "ObjectKey", # required
            value: "Value", # required
          },
        ],
      },
    },
    storage_class_analysis: { # required
      data_export: {
        output_schema_version: "V_1", # required, accepts V_1
        destination: { # required
          s3_bucket_destination: { # required
            format: "CSV", # required, accepts CSV
            bucket_account_id: "AccountId",
            bucket: "BucketName", # required
            prefix: "Prefix",
          },
        },
      },
    },
  },
})

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :bucket (required, String)

    The name of the bucket to which an analytics configuration is stored.

  • :id (required, String)

    The identifier used to represent an analytics configuration.

  • :analytics_configuration (required, Types::AnalyticsConfiguration)

    The configuration and any analyses for the analytics filter.

Returns:

  • (Struct)

    Returns an empty response.

See Also:



4570
4571
4572
4573
# File 'lib/aws-sdk-s3/client.rb', line 4570

def put_bucket_analytics_configuration(params = {}, options = {})
  req = build_request(:put_bucket_analytics_configuration, params)
  req.send_request(options)
end

#put_bucket_cors(params = {}) ⇒ Struct

Sets the CORS configuration for a bucket.

Examples:

Example: To set cors configuration on a bucket.


# The following example enables PUT, POST, and DELETE requests from www.example.com, and enables GET requests from any
# domain.

resp = client.put_bucket_cors({
  bucket: "", 
  cors_configuration: {
    cors_rules: [
      {
        allowed_headers: [
          "*", 
        ], 
        allowed_methods: [
          "PUT", 
          "POST", 
          "DELETE", 
        ], 
        allowed_origins: [
          "http://www.example.com", 
        ], 
        expose_headers: [
          "x-amz-server-side-encryption", 
        ], 
        max_age_seconds: 3000, 
      }, 
      {
        allowed_headers: [
          "Authorization", 
        ], 
        allowed_methods: [
          "GET", 
        ], 
        allowed_origins: [
          "*", 
        ], 
        max_age_seconds: 3000, 
      }, 
    ], 
  }, 
  content_md5: "", 
})

Request syntax with placeholder values


resp = client.put_bucket_cors({
  bucket: "BucketName", # required
  cors_configuration: { # required
    cors_rules: [ # required
      {
        allowed_headers: ["AllowedHeader"],
        allowed_methods: ["AllowedMethod"], # required
        allowed_origins: ["AllowedOrigin"], # required
        expose_headers: ["ExposeHeader"],
        max_age_seconds: 1,
      },
    ],
  },
  content_md5: "ContentMD5",
})

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

Returns:

  • (Struct)

    Returns an empty response.

See Also:



4651
4652
4653
4654
# File 'lib/aws-sdk-s3/client.rb', line 4651

def put_bucket_cors(params = {}, options = {})
  req = build_request(:put_bucket_cors, params)
  req.send_request(options)
end

#put_bucket_encryption(params = {}) ⇒ Struct

Creates a new server-side encryption configuration (or replaces an existing one, if present).

Examples:

Request syntax with placeholder values


resp = client.put_bucket_encryption({
  bucket: "BucketName", # required
  content_md5: "ContentMD5",
  server_side_encryption_configuration: { # required
    rules: [ # required
      {
        apply_server_side_encryption_by_default: {
          sse_algorithm: "AES256", # required, accepts AES256, aws:kms
          kms_master_key_id: "SSEKMSKeyId",
        },
      },
    ],
  },
})

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :bucket (required, String)

    The name of the bucket for which the server-side encryption configuration is set.

  • :content_md5 (String)

    The base64-encoded 128-bit MD5 digest of the server-side encryption configuration. This parameter is auto-populated when using the command from the CLI

  • :server_side_encryption_configuration (required, Types::ServerSideEncryptionConfiguration)

    Container for server-side encryption configuration rules. Currently S3 supports one rule only.

Returns:

  • (Struct)

    Returns an empty response.

See Also:



4695
4696
4697
4698
# File 'lib/aws-sdk-s3/client.rb', line 4695

def put_bucket_encryption(params = {}, options = {})
  req = build_request(:put_bucket_encryption, params)
  req.send_request(options)
end

#put_bucket_inventory_configuration(params = {}) ⇒ Struct

Adds an inventory configuration (identified by the inventory ID) from the bucket.

Examples:

Request syntax with placeholder values


resp = client.put_bucket_inventory_configuration({
  bucket: "BucketName", # required
  id: "InventoryId", # required
  inventory_configuration: { # required
    destination: { # required
      s3_bucket_destination: { # required
        account_id: "AccountId",
        bucket: "BucketName", # required
        format: "CSV", # required, accepts CSV, ORC, Parquet
        prefix: "Prefix",
        encryption: {
          sses3: {
          },
          ssekms: {
            key_id: "SSEKMSKeyId", # required
          },
        },
      },
    },
    is_enabled: false, # required
    filter: {
      prefix: "Prefix", # required
    },
    id: "InventoryId", # required
    included_object_versions: "All", # required, accepts All, Current
    optional_fields: ["Size"], # accepts Size, LastModifiedDate, StorageClass, ETag, IsMultipartUploaded, ReplicationStatus, EncryptionStatus, ObjectLockRetainUntilDate, ObjectLockMode, ObjectLockLegalHoldStatus
    schedule: { # required
      frequency: "Daily", # required, accepts Daily, Weekly
    },
  },
})

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :bucket (required, String)

    The name of the bucket where the inventory configuration will be stored.

  • :id (required, String)

    The ID used to identify the inventory configuration.

  • :inventory_configuration (required, Types::InventoryConfiguration)

    Specifies the inventory configuration.

Returns:

  • (Struct)

    Returns an empty response.

See Also:



4753
4754
4755
4756
# File 'lib/aws-sdk-s3/client.rb', line 4753

def put_bucket_inventory_configuration(params = {}, options = {})
  req = build_request(:put_bucket_inventory_configuration, params)
  req.send_request(options)
end

#put_bucket_lifecycle(params = {}) ⇒ Struct

No longer used, see the PutBucketLifecycleConfiguration operation.

Examples:

Request syntax with placeholder values


resp = client.put_bucket_lifecycle({
  bucket: "BucketName", # required
  content_md5: "ContentMD5",
  lifecycle_configuration: {
    rules: [ # required
      {
        expiration: {
          date: Time.now,
          days: 1,
          expired_object_delete_marker: false,
        },
        id: "ID",
        prefix: "Prefix", # required
        status: "Enabled", # required, accepts Enabled, Disabled
        transition: {
          date: Time.now,
          days: 1,
          storage_class: "GLACIER", # accepts GLACIER, STANDARD_IA, ONEZONE_IA, INTELLIGENT_TIERING
        },
        noncurrent_version_transition: {
          noncurrent_days: 1,
          storage_class: "GLACIER", # accepts GLACIER, STANDARD_IA, ONEZONE_IA, INTELLIGENT_TIERING
        },
        noncurrent_version_expiration: {
          noncurrent_days: 1,
        },
        abort_incomplete_multipart_upload: {
          days_after_initiation: 1,
        },
      },
    ],
  },
})

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

Returns:

  • (Struct)

    Returns an empty response.

See Also:



4808
4809
4810
4811
# File 'lib/aws-sdk-s3/client.rb', line 4808

def put_bucket_lifecycle(params = {}, options = {})
  req = build_request(:put_bucket_lifecycle, params)
  req.send_request(options)
end

#put_bucket_lifecycle_configuration(params = {}) ⇒ Struct

Sets lifecycle configuration for your bucket. If a lifecycle configuration exists, it replaces it.

Examples:

Example: Put bucket lifecycle


# The following example replaces existing lifecycle configuration, if any, on the specified bucket. 

resp = client.put_bucket_lifecycle_configuration({
  bucket: "examplebucket", 
  lifecycle_configuration: {
    rules: [
      {
        expiration: {
          days: 3650, 
        }, 
        filter: {
          prefix: "documents/", 
        }, 
        id: "TestOnly", 
        status: "Enabled", 
        transitions: [
          {
            days: 365, 
            storage_class: "GLACIER", 
          }, 
        ], 
      }, 
    ], 
  }, 
})

Request syntax with placeholder values


resp = client.put_bucket_lifecycle_configuration({
  bucket: "BucketName", # required
  lifecycle_configuration: {
    rules: [ # required
      {
        expiration: {
          date: Time.now,
          days: 1,
          expired_object_delete_marker: false,
        },
        id: "ID",
        prefix: "Prefix",
        filter: {
          prefix: "Prefix",
          tag: {
            key: "ObjectKey", # required
            value: "Value", # required
          },
          and: {
            prefix: "Prefix",
            tags: [
              {
                key: "ObjectKey", # required
                value: "Value", # required
              },
            ],
          },
        },
        status: "Enabled", # required, accepts Enabled, Disabled
        transitions: [
          {
            date: Time.now,
            days: 1,
            storage_class: "GLACIER", # accepts GLACIER, STANDARD_IA, ONEZONE_IA, INTELLIGENT_TIERING
          },
        ],
        noncurrent_version_transitions: [
          {
            noncurrent_days: 1,
            storage_class: "GLACIER", # accepts GLACIER, STANDARD_IA, ONEZONE_IA, INTELLIGENT_TIERING
          },
        ],
        noncurrent_version_expiration: {
          noncurrent_days: 1,
        },
        abort_incomplete_multipart_upload: {
          days_after_initiation: 1,
        },
      },
    ],
  },
})

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

Returns:

  • (Struct)

    Returns an empty response.

See Also:



4910
4911
4912
4913
# File 'lib/aws-sdk-s3/client.rb', line 4910

def put_bucket_lifecycle_configuration(params = {}, options = {})
  req = build_request(:put_bucket_lifecycle_configuration, params)
  req.send_request(options)
end

#put_bucket_logging(params = {}) ⇒ Struct

Set the logging parameters for a bucket and to specify permissions for who can view and modify the logging parameters. To set the logging status of a bucket, you must be the bucket owner.

Examples:

Example: Set logging configuration for a bucket


# The following example sets logging policy on a bucket. For the Log Delivery group to deliver logs to the destination
# bucket, it needs permission for the READ_ACP action which the policy grants.

resp = client.put_bucket_logging({
  bucket: "sourcebucket", 
  bucket_logging_status: {
    logging_enabled: {
      target_bucket: "targetbucket", 
      target_grants: [
        {
          grantee: {
            type: "Group", 
            uri: "http://acs.amazonaws.com/groups/global/AllUsers", 
          }, 
          permission: "READ", 
        }, 
      ], 
      target_prefix: "MyBucketLogs/", 
    }, 
  }, 
})

Request syntax with placeholder values


resp = client.put_bucket_logging({
  bucket: "BucketName", # required
  bucket_logging_status: { # required
    logging_enabled: {
      target_bucket: "TargetBucket", # required
      target_grants: [
        {
          grantee: {
            display_name: "DisplayName",
            email_address: "EmailAddress",
            id: "ID",
            type: "CanonicalUser", # required, accepts CanonicalUser, AmazonCustomerByEmail, Group
            uri: "URI",
          },
          permission: "FULL_CONTROL", # accepts FULL_CONTROL, READ, WRITE
        },
      ],
      target_prefix: "TargetPrefix", # required
    },
  },
  content_md5: "ContentMD5",
})

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

Returns:

  • (Struct)

    Returns an empty response.

See Also:



4981
4982
4983
4984
# File 'lib/aws-sdk-s3/client.rb', line 4981

def put_bucket_logging(params = {}, options = {})
  req = build_request(:put_bucket_logging, params)
  req.send_request(options)
end

#put_bucket_metrics_configuration(params = {}) ⇒ Struct

Sets a metrics configuration (specified by the metrics configuration ID) for the bucket.

Examples:

Request syntax with placeholder values


resp = client.put_bucket_metrics_configuration({
  bucket: "BucketName", # required
  id: "MetricsId", # required
  metrics_configuration: { # required
    id: "MetricsId", # required
    filter: {
      prefix: "Prefix",
      tag: {
        key: "ObjectKey", # required
        value: "Value", # required
      },
      and: {
        prefix: "Prefix",
        tags: [
          {
            key: "ObjectKey", # required
            value: "Value", # required
          },
        ],
      },
    },
  },
})

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :bucket (required, String)

    The name of the bucket for which the metrics configuration is set.

  • :id (required, String)

    The ID used to identify the metrics configuration.

  • :metrics_configuration (required, Types::MetricsConfiguration)

    Specifies the metrics configuration.

Returns:

  • (Struct)

    Returns an empty response.

See Also:



5030
5031
5032
5033
# File 'lib/aws-sdk-s3/client.rb', line 5030

def put_bucket_metrics_configuration(params = {}, options = {})
  req = build_request(:put_bucket_metrics_configuration, params)
  req.send_request(options)
end

#put_bucket_notification(params = {}) ⇒ Struct

No longer used, see the PutBucketNotificationConfiguration operation.

Examples:

Request syntax with placeholder values


resp = client.put_bucket_notification({
  bucket: "BucketName", # required
  content_md5: "ContentMD5",
  notification_configuration: { # required
    topic_configuration: {
      id: "NotificationId",
      events: ["s3:ReducedRedundancyLostObject"], # accepts s3:ReducedRedundancyLostObject, s3:ObjectCreated:*, s3:ObjectCreated:Put, s3:ObjectCreated:Post, s3:ObjectCreated:Copy, s3:ObjectCreated:CompleteMultipartUpload, s3:ObjectRemoved:*, s3:ObjectRemoved:Delete, s3:ObjectRemoved:DeleteMarkerCreated, s3:ObjectRestore:Post, s3:ObjectRestore:Completed
      event: "s3:ReducedRedundancyLostObject", # accepts s3:ReducedRedundancyLostObject, s3:ObjectCreated:*, s3:ObjectCreated:Put, s3:ObjectCreated:Post, s3:ObjectCreated:Copy, s3:ObjectCreated:CompleteMultipartUpload, s3:ObjectRemoved:*, s3:ObjectRemoved:Delete, s3:ObjectRemoved:DeleteMarkerCreated, s3:ObjectRestore:Post, s3:ObjectRestore:Completed
      topic: "TopicArn",
    },
    queue_configuration: {
      id: "NotificationId",
      event: "s3:ReducedRedundancyLostObject", # accepts s3:ReducedRedundancyLostObject, s3:ObjectCreated:*, s3:ObjectCreated:Put, s3:ObjectCreated:Post, s3:ObjectCreated:Copy, s3:ObjectCreated:CompleteMultipartUpload, s3:ObjectRemoved:*, s3:ObjectRemoved:Delete, s3:ObjectRemoved:DeleteMarkerCreated, s3:ObjectRestore:Post, s3:ObjectRestore:Completed
      events: ["s3:ReducedRedundancyLostObject"], # accepts s3:ReducedRedundancyLostObject, s3:ObjectCreated:*, s3:ObjectCreated:Put, s3:ObjectCreated:Post, s3:ObjectCreated:Copy, s3:ObjectCreated:CompleteMultipartUpload, s3:ObjectRemoved:*, s3:ObjectRemoved:Delete, s3:ObjectRemoved:DeleteMarkerCreated, s3:ObjectRestore:Post, s3:ObjectRestore:Completed
      queue: "QueueArn",
    },
    cloud_function_configuration: {
      id: "NotificationId",
      event: "s3:ReducedRedundancyLostObject", # accepts s3:ReducedRedundancyLostObject, s3:ObjectCreated:*, s3:ObjectCreated:Put, s3:ObjectCreated:Post, s3:ObjectCreated:Copy, s3:ObjectCreated:CompleteMultipartUpload, s3:ObjectRemoved:*, s3:ObjectRemoved:Delete, s3:ObjectRemoved:DeleteMarkerCreated, s3:ObjectRestore:Post, s3:ObjectRestore:Completed
      events: ["s3:ReducedRedundancyLostObject"], # accepts s3:ReducedRedundancyLostObject, s3:ObjectCreated:*, s3:ObjectCreated:Put, s3:ObjectCreated:Post, s3:ObjectCreated:Copy, s3:ObjectCreated:CompleteMultipartUpload, s3:ObjectRemoved:*, s3:ObjectRemoved:Delete, s3:ObjectRemoved:DeleteMarkerCreated, s3:ObjectRestore:Post, s3:ObjectRestore:Completed
      cloud_function: "CloudFunction",
      invocation_role: "CloudFunctionInvocationRole",
    },
  },
})

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

Returns:

  • (Struct)

    Returns an empty response.

See Also:



5077
5078
5079
5080
# File 'lib/aws-sdk-s3/client.rb', line 5077

def put_bucket_notification(params = {}, options = {})
  req = build_request(:put_bucket_notification, params)
  req.send_request(options)
end

#put_bucket_notification_configuration(params = {}) ⇒ Struct

Enables notifications of specified events for a bucket.

Examples:

Example: Set notification configuration for a bucket


# The following example sets notification configuration on a bucket to publish the object created events to an SNS topic.

resp = client.put_bucket_notification_configuration({
  bucket: "examplebucket", 
  notification_configuration: {
    topic_configurations: [
      {
        events: [
          "s3:ObjectCreated:*", 
        ], 
        topic_arn: "arn:aws:sns:us-west-2:123456789012:s3-notification-topic", 
      }, 
    ], 
  }, 
})

Request syntax with placeholder values


resp = client.put_bucket_notification_configuration({
  bucket: "BucketName", # required
  notification_configuration: { # required
    topic_configurations: [
      {
        id: "NotificationId",
        topic_arn: "TopicArn", # required
        events: ["s3:ReducedRedundancyLostObject"], # required, accepts s3:ReducedRedundancyLostObject, s3:ObjectCreated:*, s3:ObjectCreated:Put, s3:ObjectCreated:Post, s3:ObjectCreated:Copy, s3:ObjectCreated:CompleteMultipartUpload, s3:ObjectRemoved:*, s3:ObjectRemoved:Delete, s3:ObjectRemoved:DeleteMarkerCreated, s3:ObjectRestore:Post, s3:ObjectRestore:Completed
        filter: {
          key: {
            filter_rules: [
              {
                name: "prefix", # accepts prefix, suffix
                value: "FilterRuleValue",
              },
            ],
          },
        },
      },
    ],
    queue_configurations: [
      {
        id: "NotificationId",
        queue_arn: "QueueArn", # required
        events: ["s3:ReducedRedundancyLostObject"], # required, accepts s3:ReducedRedundancyLostObject, s3:ObjectCreated:*, s3:ObjectCreated:Put, s3:ObjectCreated:Post, s3:ObjectCreated:Copy, s3:ObjectCreated:CompleteMultipartUpload, s3:ObjectRemoved:*, s3:ObjectRemoved:Delete, s3:ObjectRemoved:DeleteMarkerCreated, s3:ObjectRestore:Post, s3:ObjectRestore:Completed
        filter: {
          key: {
            filter_rules: [
              {
                name: "prefix", # accepts prefix, suffix
                value: "FilterRuleValue",
              },
            ],
          },
        },
      },
    ],
    lambda_function_configurations: [
      {
        id: "NotificationId",
        lambda_function_arn: "LambdaFunctionArn", # required
        events: ["s3:ReducedRedundancyLostObject"], # required, accepts s3:ReducedRedundancyLostObject, s3:ObjectCreated:*, s3:ObjectCreated:Put, s3:ObjectCreated:Post, s3:ObjectCreated:Copy, s3:ObjectCreated:CompleteMultipartUpload, s3:ObjectRemoved:*, s3:ObjectRemoved:Delete, s3:ObjectRemoved:DeleteMarkerCreated, s3:ObjectRestore:Post, s3:ObjectRestore:Completed
        filter: {
          key: {
            filter_rules: [
              {
                name: "prefix", # accepts prefix, suffix
                value: "FilterRuleValue",
              },
            ],
          },
        },
      },
    ],
  },
})

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :bucket (required, String)
  • :notification_configuration (required, Types::NotificationConfiguration)

    A container for specifying the notification configuration of the bucket. If this element is empty, notifications are turned off for the bucket.

Returns:

  • (Struct)

    Returns an empty response.

See Also:



5175
5176
5177
5178
# File 'lib/aws-sdk-s3/client.rb', line 5175

def put_bucket_notification_configuration(params = {}, options = {})
  req = build_request(:put_bucket_notification_configuration, params)
  req.send_request(options)
end

#put_bucket_policy(params = {}) ⇒ Struct

Replaces a policy on a bucket. If the bucket already has a policy, the one in this request completely replaces it.

Examples:

Example: Set bucket policy


# The following example sets a permission policy on a bucket.

resp = client.put_bucket_policy({
  bucket: "examplebucket", 
  policy: "{\"Version\": \"2012-10-17\", \"Statement\": [{ \"Sid\": \"id-1\",\"Effect\": \"Allow\",\"Principal\": {\"AWS\": \"arn:aws:iam::123456789012:root\"}, \"Action\": [ \"s3:PutObject\",\"s3:PutObjectAcl\"], \"Resource\": [\"arn:aws:s3:::acl3/*\" ] } ]}", 
})

Request syntax with placeholder values


resp = client.put_bucket_policy({
  bucket: "BucketName", # required
  content_md5: "ContentMD5",
  confirm_remove_self_bucket_access: false,
  policy: "Policy", # required
})

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :bucket (required, String)
  • :content_md5 (String)
  • :confirm_remove_self_bucket_access (Boolean)

    Set this parameter to true to confirm that you want to remove your permissions to change this bucket policy in the future.

  • :policy (required, String)

    The bucket policy as a JSON document.

Returns:

  • (Struct)

    Returns an empty response.

See Also:



5219
5220
5221
5222
# File 'lib/aws-sdk-s3/client.rb', line 5219

def put_bucket_policy(params = {}, options = {})
  req = build_request(:put_bucket_policy, params)
  req.send_request(options)
end

#put_bucket_replication(params = {}) ⇒ Struct

Creates a replication configuration or replaces an existing one. For more information, see [Cross-Region Replication (CRR)]( docs.aws.amazon.com/AmazonS3/latest/dev/crr.html) in the *Amazon S3 Developer Guide*.

Examples:

Example: Set replication configuration on a bucket


# The following example sets replication configuration on a bucket.

resp = client.put_bucket_replication({
  bucket: "examplebucket", 
  replication_configuration: {
    role: "arn:aws:iam::123456789012:role/examplerole", 
    rules: [
      {
        destination: {
          bucket: "arn:aws:s3:::destinationbucket", 
          storage_class: "STANDARD", 
        }, 
        prefix: "", 
        status: "Enabled", 
      }, 
    ], 
  }, 
})

Request syntax with placeholder values


resp = client.put_bucket_replication({
  bucket: "BucketName", # required
  content_md5: "ContentMD5",
  replication_configuration: { # required
    role: "Role", # required
    rules: [ # required
      {
        id: "ID",
        priority: 1,
        prefix: "Prefix",
        filter: {
          prefix: "Prefix",
          tag: {
            key: "ObjectKey", # required
            value: "Value", # required
          },
          and: {
            prefix: "Prefix",
            tags: [
              {
                key: "ObjectKey", # required
                value: "Value", # required
              },
            ],
          },
        },
        status: "Enabled", # required, accepts Enabled, Disabled
        source_selection_criteria: {
          sse_kms_encrypted_objects: {
            status: "Enabled", # required, accepts Enabled, Disabled
          },
        },
        destination: { # required
          bucket: "BucketName", # required
          account: "AccountId",
          storage_class: "STANDARD", # accepts STANDARD, REDUCED_REDUNDANCY, STANDARD_IA, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER
          access_control_translation: {
            owner: "Destination", # required, accepts Destination
          },
          encryption_configuration: {
            replica_kms_key_id: "ReplicaKmsKeyID",
          },
        },
        delete_marker_replication: {
          status: "Enabled", # accepts Enabled, Disabled
        },
      },
    ],
  },
})

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :bucket (required, String)
  • :content_md5 (String)
  • :replication_configuration (required, Types::ReplicationConfiguration)

    A container for replication rules. You can add up to 1,000 rules. The maximum size of a replication configuration is 2 MB.

Returns:

  • (Struct)

    Returns an empty response.

See Also:



5318
5319
5320
5321
# File 'lib/aws-sdk-s3/client.rb', line 5318

def put_bucket_replication(params = {}, options = {})
  req = build_request(:put_bucket_replication, params)
  req.send_request(options)
end

#put_bucket_request_payment(params = {}) ⇒ Struct

Sets the request payment configuration for a bucket. By default, the bucket owner pays for downloads from the bucket. This configuration parameter enables the bucket owner (only) to specify that the person requesting the download will be charged for the download. Documentation on requester pays buckets can be found at docs.aws.amazon.com/AmazonS3/latest/dev/RequesterPaysBuckets.html

Examples:

Example: Set request payment configuration on a bucket.


# The following example sets request payment configuration on a bucket so that person requesting the download is charged.

resp = client.put_bucket_request_payment({
  bucket: "examplebucket", 
  request_payment_configuration: {
    payer: "Requester", 
  }, 
})

Request syntax with placeholder values


resp = client.put_bucket_request_payment({
  bucket: "BucketName", # required
  content_md5: "ContentMD5",
  request_payment_configuration: { # required
    payer: "Requester", # required, accepts Requester, BucketOwner
  },
})

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

Returns:

  • (Struct)

    Returns an empty response.

See Also:



5364
5365
5366
5367
# File 'lib/aws-sdk-s3/client.rb', line 5364

def put_bucket_request_payment(params = {}, options = {})
  req = build_request(:put_bucket_request_payment, params)
  req.send_request(options)
end

#put_bucket_tagging(params = {}) ⇒ Struct

Sets the tags for a bucket.

Examples:

Example: Set tags on a bucket


# The following example sets tags on a bucket. Any existing tags are replaced.

resp = client.put_bucket_tagging({
  bucket: "examplebucket", 
  tagging: {
    tag_set: [
      {
        key: "Key1", 
        value: "Value1", 
      }, 
      {
        key: "Key2", 
        value: "Value2", 
      }, 
    ], 
  }, 
})

Request syntax with placeholder values


resp = client.put_bucket_tagging({
  bucket: "BucketName", # required
  content_md5: "ContentMD5",
  tagging: { # required
    tag_set: [ # required
      {
        key: "ObjectKey", # required
        value: "Value", # required
      },
    ],
  },
})

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :bucket (required, String)
  • :content_md5 (String)
  • :tagging (required, Types::Tagging)

Returns:

  • (Struct)

    Returns an empty response.

See Also:



5419
5420
5421
5422
# File 'lib/aws-sdk-s3/client.rb', line 5419

def put_bucket_tagging(params = {}, options = {})
  req = build_request(:put_bucket_tagging, params)
  req.send_request(options)
end

#put_bucket_versioning(params = {}) ⇒ Struct

Sets the versioning state of an existing bucket. To set the versioning state, you must be the bucket owner.

Examples:

Example: Set versioning configuration on a bucket


# The following example sets versioning configuration on bucket. The configuration enables versioning on the bucket.

resp = client.put_bucket_versioning({
  bucket: "examplebucket", 
  versioning_configuration: {
    mfa_delete: "Disabled", 
    status: "Enabled", 
  }, 
})

Request syntax with placeholder values


resp = client.put_bucket_versioning({
  bucket: "BucketName", # required
  content_md5: "ContentMD5",
  mfa: "MFA",
  versioning_configuration: { # required
    mfa_delete: "Enabled", # accepts Enabled, Disabled
    status: "Enabled", # accepts Enabled, Suspended
  },
})

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :bucket (required, String)
  • :content_md5 (String)
  • :mfa (String)

    The concatenation of the authentication device’s serial number, a space, and the value that is displayed on your authentication device.

  • :versioning_configuration (required, Types::VersioningConfiguration)

Returns:

  • (Struct)

    Returns an empty response.

See Also:



5468
5469
5470
5471
# File 'lib/aws-sdk-s3/client.rb', line 5468

def put_bucket_versioning(params = {}, options = {})
  req = build_request(:put_bucket_versioning, params)
  req.send_request(options)
end

#put_bucket_website(params = {}) ⇒ Struct

Set the website configuration for a bucket.

Examples:

Example: Set website configuration on a bucket


# The following example adds website configuration to a bucket.

resp = client.put_bucket_website({
  bucket: "examplebucket", 
  content_md5: "", 
  website_configuration: {
    error_document: {
      key: "error.html", 
    }, 
    index_document: {
      suffix: "index.html", 
    }, 
  }, 
})

Request syntax with placeholder values


resp = client.put_bucket_website({
  bucket: "BucketName", # required
  content_md5: "ContentMD5",
  website_configuration: { # required
    error_document: {
      key: "ObjectKey", # required
    },
    index_document: {
      suffix: "Suffix", # required
    },
    redirect_all_requests_to: {
      host_name: "HostName", # required
      protocol: "http", # accepts http, https
    },
    routing_rules: [
      {
        condition: {
          http_error_code_returned_equals: "HttpErrorCodeReturnedEquals",
          key_prefix_equals: "KeyPrefixEquals",
        },
        redirect: { # required
          host_name: "HostName",
          http_redirect_code: "HttpRedirectCode",
          protocol: "http", # accepts http, https
          replace_key_prefix_with: "ReplaceKeyPrefixWith",
          replace_key_with: "ReplaceKeyWith",
        },
      },
    ],
  },
})

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

Returns:

  • (Struct)

    Returns an empty response.

See Also:



5539
5540
5541
5542
# File 'lib/aws-sdk-s3/client.rb', line 5539

def put_bucket_website(params = {}, options = {})
  req = build_request(:put_bucket_website, params)
  req.send_request(options)
end

#put_object(params = {}) ⇒ Types::PutObjectOutput

Adds an object to a bucket.

Examples:

Example: To upload an object and specify canned ACL.


# The following example uploads and object. The request specifies optional canned ACL (access control list) to all READ
# access to authenticated users. If the bucket is versioning enabled, S3 returns version ID in response.

resp = client.put_object({
  acl: "authenticated-read", 
  body: "filetoupload", 
  bucket: "examplebucket", 
  key: "exampleobject", 
})

resp.to_h outputs the following:
{
  etag: "\"6805f2cfc46c0f04559748bb039d69ae\"", 
  version_id: "Kirh.unyZwjQ69YxcQLA8z4F5j3kJJKr", 
}

Example: To upload an object


# The following example uploads an object to a versioning-enabled bucket. The source file is specified using Windows file
# syntax. S3 returns VersionId of the newly created object.

resp = client.put_object({
  body: "HappyFace.jpg", 
  bucket: "examplebucket", 
  key: "HappyFace.jpg", 
})

resp.to_h outputs the following:
{
  etag: "\"6805f2cfc46c0f04559748bb039d69ae\"", 
  version_id: "tpf3zF08nBplQK1XLOefGskR7mGDwcDk", 
}

Example: To create an object.


# The following example creates an object. If the bucket is versioning enabled, S3 returns version ID in response.

resp = client.put_object({
  body: "filetoupload", 
  bucket: "examplebucket", 
  key: "objectkey", 
})

resp.to_h outputs the following:
{
  etag: "\"6805f2cfc46c0f04559748bb039d69ae\"", 
  version_id: "Bvq0EDKxOcXLJXNo_Lkz37eM3R4pfzyQ", 
}

Example: To upload object and specify user-defined metadata


# The following example creates an object. The request also specifies optional metadata. If the bucket is versioning
# enabled, S3 returns version ID in response.

resp = client.put_object({
  body: "filetoupload", 
  bucket: "examplebucket", 
  key: "exampleobject", 
  metadata: {
    "metadata1" => "value1", 
    "metadata2" => "value2", 
  }, 
})

resp.to_h outputs the following:
{
  etag: "\"6805f2cfc46c0f04559748bb039d69ae\"", 
  version_id: "pSKidl4pHBiNwukdbcPXAIs.sshFFOc0", 
}

Example: To upload an object and specify optional tags


# The following example uploads an object. The request specifies optional object tags. The bucket is versioned, therefore
# S3 returns version ID of the newly created object.

resp = client.put_object({
  body: "c:\\HappyFace.jpg", 
  bucket: "examplebucket", 
  key: "HappyFace.jpg", 
  tagging: "key1=value1&key2=value2", 
})

resp.to_h outputs the following:
{
  etag: "\"6805f2cfc46c0f04559748bb039d69ae\"", 
  version_id: "psM2sYY4.o1501dSx8wMvnkOzSBB.V4a", 
}

Example: To upload an object and specify server-side encryption and object tags


# The following example uploads and object. The request specifies the optional server-side encryption option. The request
# also specifies optional object tags. If the bucket is versioning enabled, S3 returns version ID in response.

resp = client.put_object({
  body: "filetoupload", 
  bucket: "examplebucket", 
  key: "exampleobject", 
  server_side_encryption: "AES256", 
  tagging: "key1=value1&key2=value2", 
})

resp.to_h outputs the following:
{
  etag: "\"6805f2cfc46c0f04559748bb039d69ae\"", 
  server_side_encryption: "AES256", 
  version_id: "Ri.vC6qVlA4dEnjgRV4ZHsHoFIjqEMNt", 
}

Example: To upload an object (specify optional headers)


# The following example uploads an object. The request specifies optional request headers to directs S3 to use specific
# storage class and use server-side encryption.

resp = client.put_object({
  body: "HappyFace.jpg", 
  bucket: "examplebucket", 
  key: "HappyFace.jpg", 
  server_side_encryption: "AES256", 
  storage_class: "STANDARD_IA", 
})

resp.to_h outputs the following:
{
  etag: "\"6805f2cfc46c0f04559748bb039d69ae\"", 
  server_side_encryption: "AES256", 
  version_id: "CG612hodqujkf8FaaNfp8U..FIhLROcp", 
}

Streaming a file from disk

# upload file from disk in a single request, may not exceed 5GB
File.open('/source/file/path', 'rb') do |file|
  s3.put_object(bucket: 'bucket-name', key: 'object-key', body: file)
end

Request syntax with placeholder values


resp = client.put_object({
  acl: "private", # accepts private, public-read, public-read-write, authenticated-read, aws-exec-read, bucket-owner-read, bucket-owner-full-control
  body: source_file,
  bucket: "BucketName", # required
  cache_control: "CacheControl",
  content_disposition: "ContentDisposition",
  content_encoding: "ContentEncoding",
  content_language: "ContentLanguage",
  content_length: 1,
  content_md5: "ContentMD5",
  content_type: "ContentType",
  expires: Time.now,
  grant_full_control: "GrantFullControl",
  grant_read: "GrantRead",
  grant_read_acp: "GrantReadACP",
  grant_write_acp: "GrantWriteACP",
  key: "ObjectKey", # required
  metadata: {
    "MetadataKey" => "MetadataValue",
  },
  server_side_encryption: "AES256", # accepts AES256, aws:kms
  storage_class: "STANDARD", # accepts STANDARD, REDUCED_REDUNDANCY, STANDARD_IA, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER
  website_redirect_location: "WebsiteRedirectLocation",
  sse_customer_algorithm: "SSECustomerAlgorithm",
  sse_customer_key: "SSECustomerKey",
  sse_customer_key_md5: "SSECustomerKeyMD5",
  ssekms_key_id: "SSEKMSKeyId",
  request_payer: "requester", # accepts requester
  tagging: "TaggingHeader",
  object_lock_mode: "GOVERNANCE", # accepts GOVERNANCE, COMPLIANCE
  object_lock_retain_until_date: Time.now,
  object_lock_legal_hold_status: "ON", # accepts ON, OFF
})

Response structure


resp.expiration #=> String
resp.etag #=> String
resp.server_side_encryption #=> String, one of "AES256", "aws:kms"
resp.version_id #=> String
resp.sse_customer_algorithm #=> String
resp.sse_customer_key_md5 #=> String
resp.ssekms_key_id #=> String
resp.request_charged #=> String, one of "requester"

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :acl (String)

    The canned ACL to apply to the object.

  • :body (String, IO)

    Object data.

  • :bucket (required, String)

    Name of the bucket to which the PUT operation was initiated.

  • :cache_control (String)

    Specifies caching behavior along the request/reply chain.

  • :content_disposition (String)

    Specifies presentational information for the object.

  • :content_encoding (String)

    Specifies what content encodings have been applied to the object and thus what decoding mechanisms must be applied to obtain the media-type referenced by the Content-Type header field.

  • :content_language (String)

    The language the content is in.

  • :content_length (Integer)

    Size of the body in bytes. This parameter is useful when the size of the body cannot be determined automatically.

  • :content_md5 (String)

    The base64-encoded 128-bit MD5 digest of the part data. This parameter is auto-populated when using the command from the CLI

  • :content_type (String)

    A standard MIME type describing the format of the object data.

  • :expires (Time, DateTime, Date, Integer, String)

    The date and time at which the object is no longer cacheable.

  • :grant_full_control (String)

    Gives the grantee READ, READ_ACP, and WRITE_ACP permissions on the object.

  • :grant_read (String)

    Allows grantee to read the object data and its metadata.

  • :grant_read_acp (String)

    Allows grantee to read the object ACL.

  • :grant_write_acp (String)

    Allows grantee to write the ACL for the applicable object.

  • :key (required, String)

    Object key for which the PUT operation was initiated.

  • :metadata (Hash<String,String>)

    A map of metadata to store with the object in S3.

  • :server_side_encryption (String)

    The Server-side encryption algorithm used when storing this object in S3 (e.g., AES256, aws:kms).

  • :storage_class (String)

    The type of storage to use for the object. Defaults to ‘STANDARD’.

  • :website_redirect_location (String)

    If the bucket is configured as a website, redirects requests for this object to another object in the same bucket or to an external URL. Amazon S3 stores the value of this header in the object metadata.

  • :sse_customer_algorithm (String)

    Specifies the algorithm to use to when encrypting the object (e.g., AES256).

  • :sse_customer_key (String)

    Specifies the customer-provided encryption key for Amazon S3 to use in encrypting data. This value is used to store the object and then it is discarded; Amazon does not store the encryption key. The key must be appropriate for use with the algorithm specified in the x-amz-server-side​-encryption​-customer-algorithm header.

  • :sse_customer_key_md5 (String)

    Specifies the 128-bit MD5 digest of the encryption key according to RFC 1321. Amazon S3 uses this header for a message integrity check to ensure the encryption key was transmitted without error.

  • :ssekms_key_id (String)

    Specifies the AWS KMS key ID to use for object encryption. All GET and PUT requests for an object protected by AWS KMS will fail if not made via SSL or using SigV4. Documentation on configuring any of the officially supported AWS SDKs and CLI can be found at docs.aws.amazon.com/AmazonS3/latest/dev/UsingAWSSDK.html#specify-signature-version

  • :request_payer (String)

    Confirms that the requester knows that she or he will be charged for the request. Bucket owners need not specify this parameter in their requests. Documentation on downloading objects from requester pays buckets can be found at docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html

  • :tagging (String)

    The tag-set for the object. The tag-set must be encoded as URL Query parameters. (For example, “Key1=Value1”)

  • :object_lock_mode (String)

    The Object Lock mode that you want to apply to this object.

  • :object_lock_retain_until_date (Time, DateTime, Date, Integer, String)

    The date and time when you want this object’s Object Lock to expire.

  • :object_lock_legal_hold_status (String)

    The Legal Hold status that you want to apply to the specified object.

Returns:

See Also:



5856
5857
5858
5859
# File 'lib/aws-sdk-s3/client.rb', line 5856

def put_object(params = {}, options = {})
  req = build_request(:put_object, params)
  req.send_request(options)
end

#put_object_acl(params = {}) ⇒ Types::PutObjectAclOutput

uses the acl subresource to set the access control list (ACL) permissions for an object that already exists in a bucket

Examples:

Example: To grant permissions using object ACL


# The following example adds grants to an object ACL. The first permission grants user1 and user2 FULL_CONTROL and the
# AllUsers group READ permission.

resp = client.put_object_acl({
  access_control_policy: {
  }, 
  bucket: "examplebucket", 
  grant_full_control: "[email protected],[email protected]", 
  grant_read: "uri=http://acs.amazonaws.com/groups/global/AllUsers", 
  key: "HappyFace.jpg", 
})

resp.to_h outputs the following:
{
}

Request syntax with placeholder values


resp = client.put_object_acl({
  acl: "private", # accepts private, public-read, public-read-write, authenticated-read, aws-exec-read, bucket-owner-read, bucket-owner-full-control
  access_control_policy: {
    grants: [
      {
        grantee: {
          display_name: "DisplayName",
          email_address: "EmailAddress",
          id: "ID",
          type: "CanonicalUser", # required, accepts CanonicalUser, AmazonCustomerByEmail, Group
          uri: "URI",
        },
        permission: "FULL_CONTROL", # accepts FULL_CONTROL, WRITE, WRITE_ACP, READ, READ_ACP
      },
    ],
    owner: {
      display_name: "DisplayName",
      id: "ID",
    },
  },
  bucket: "BucketName", # required
  content_md5: "ContentMD5",
  grant_full_control: "GrantFullControl",
  grant_read: "GrantRead",
  grant_read_acp: "GrantReadACP",
  grant_write: "GrantWrite",
  grant_write_acp: "GrantWriteACP",
  key: "ObjectKey", # required
  request_payer: "requester", # accepts requester
  version_id: "ObjectVersionId",
})

Response structure


resp.request_charged #=> String, one of "requester"

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :acl (String)

    The canned ACL to apply to the object.

  • :access_control_policy (Types::AccessControlPolicy)
  • :bucket (required, String)
  • :content_md5 (String)
  • :grant_full_control (String)

    Allows grantee the read, write, read ACP, and write ACP permissions on the bucket.

  • :grant_read (String)

    Allows grantee to list the objects in the bucket.

  • :grant_read_acp (String)

    Allows grantee to read the bucket ACL.

  • :grant_write (String)

    Allows grantee to create, overwrite, and delete any object in the bucket.

  • :grant_write_acp (String)

    Allows grantee to write the ACL for the applicable bucket.

  • :key (required, String)
  • :request_payer (String)

    Confirms that the requester knows that she or he will be charged for the request. Bucket owners need not specify this parameter in their requests. Documentation on downloading objects from requester pays buckets can be found at docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html

  • :version_id (String)

    VersionId used to reference a specific version of the object.

Returns:

See Also:



5967
5968
5969
5970
# File 'lib/aws-sdk-s3/client.rb', line 5967

def put_object_acl(params = {}, options = {})
  req = build_request(:put_object_acl, params)
  req.send_request(options)
end

Applies a Legal Hold configuration to the specified object.

Examples:

Request syntax with placeholder values


resp = client.put_object_legal_hold({
  bucket: "BucketName", # required
  key: "ObjectKey", # required
  legal_hold: {
    status: "ON", # accepts ON, OFF
  },
  request_payer: "requester", # accepts requester
  version_id: "ObjectVersionId",
  content_md5: "ContentMD5",
})

Response structure


resp.request_charged #=> String, one of "requester"

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :bucket (required, String)

    The bucket containing the object that you want to place a Legal Hold on.

  • :key (required, String)

    The key name for the object that you want to place a Legal Hold on.

  • :legal_hold (Types::ObjectLockLegalHold)

    Container element for the Legal Hold configuration you want to apply to the specified object.

  • :request_payer (String)

    Confirms that the requester knows that she or he will be charged for the request. Bucket owners need not specify this parameter in their requests. Documentation on downloading objects from requester pays buckets can be found at docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html

  • :version_id (String)

    The version ID of the object that you want to place a Legal Hold on.

  • :content_md5 (String)

    The MD5 hash for the request body.

Returns:

See Also:



6023
6024
6025
6026
# File 'lib/aws-sdk-s3/client.rb', line 6023

def put_object_legal_hold(params = {}, options = {})
  req = build_request(:put_object_legal_hold, params)
  req.send_request(options)
end

#put_object_lock_configuration(params = {}) ⇒ Types::PutObjectLockConfigurationOutput

Places an Object Lock configuration on the specified bucket. The rule specified in the Object Lock configuration will be applied by default to every new object placed in the specified bucket.

Examples:

Request syntax with placeholder values


resp = client.put_object_lock_configuration({
  bucket: "BucketName", # required
  object_lock_configuration: {
    object_lock_enabled: "Enabled", # accepts Enabled
    rule: {
      default_retention: {
        mode: "GOVERNANCE", # accepts GOVERNANCE, COMPLIANCE
        days: 1,
        years: 1,
      },
    },
  },
  request_payer: "requester", # accepts requester
  token: "ObjectLockToken",
  content_md5: "ContentMD5",
})

Response structure


resp.request_charged #=> String, one of "requester"

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :bucket (required, String)

    The bucket whose Object Lock configuration you want to create or replace.

  • :object_lock_configuration (Types::ObjectLockConfiguration)

    The Object Lock configuration that you want to apply to the specified bucket.

  • :request_payer (String)

    Confirms that the requester knows that she or he will be charged for the request. Bucket owners need not specify this parameter in their requests. Documentation on downloading objects from requester pays buckets can be found at docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html

  • :token (String)

    A token to allow Object Lock to be enabled for an existing bucket.

  • :content_md5 (String)

    The MD5 hash for the request body.

Returns:

See Also:



6084
6085
6086
6087
# File 'lib/aws-sdk-s3/client.rb', line 6084

def put_object_lock_configuration(params = {}, options = {})
  req = build_request(:put_object_lock_configuration, params)
  req.send_request(options)
end

#put_object_retention(params = {}) ⇒ Types::PutObjectRetentionOutput

Places an Object Retention configuration on an object.

Examples:

Request syntax with placeholder values


resp = client.put_object_retention({
  bucket: "BucketName", # required
  key: "ObjectKey", # required
  retention: {
    mode: "GOVERNANCE", # accepts GOVERNANCE, COMPLIANCE
    retain_until_date: Time.now,
  },
  request_payer: "requester", # accepts requester
  version_id: "ObjectVersionId",
  bypass_governance_retention: false,
  content_md5: "ContentMD5",
})

Response structure


resp.request_charged #=> String, one of "requester"

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :bucket (required, String)

    The bucket that contains the object you want to apply this Object Retention configuration to.

  • :key (required, String)

    The key name for the object that you want to apply this Object Retention configuration to.

  • :retention (Types::ObjectLockRetention)

    The container element for the Object Retention configuration.

  • :request_payer (String)

    Confirms that the requester knows that she or he will be charged for the request. Bucket owners need not specify this parameter in their requests. Documentation on downloading objects from requester pays buckets can be found at docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html

  • :version_id (String)

    The version ID for the object that you want to apply this Object Retention configuration to.

  • :bypass_governance_retention (Boolean)

    Indicates whether this operation should bypass Governance-mode restrictions.j

  • :content_md5 (String)

    The MD5 hash for the request body.

Returns:

See Also:



6147
6148
6149
6150
# File 'lib/aws-sdk-s3/client.rb', line 6147

def put_object_retention(params = {}, options = {})
  req = build_request(:put_object_retention, params)
  req.send_request(options)
end

#put_object_tagging(params = {}) ⇒ Types::PutObjectTaggingOutput

Sets the supplied tag-set to an object that already exists in a bucket

Examples:

Example: To add tags to an existing object


# The following example adds tags to an existing object.

resp = client.put_object_tagging({
  bucket: "examplebucket", 
  key: "HappyFace.jpg", 
  tagging: {
    tag_set: [
      {
        key: "Key3", 
        value: "Value3", 
      }, 
      {
        key: "Key4", 
        value: "Value4", 
      }, 
    ], 
  }, 
})

resp.to_h outputs the following:
{
  version_id: "null", 
}

Request syntax with placeholder values


resp = client.put_object_tagging({
  bucket: "BucketName", # required
  key: "ObjectKey", # required
  version_id: "ObjectVersionId",
  content_md5: "ContentMD5",
  tagging: { # required
    tag_set: [ # required
      {
        key: "ObjectKey", # required
        value: "Value", # required
      },
    ],
  },
})

Response structure


resp.version_id #=> String

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :bucket (required, String)
  • :key (required, String)
  • :version_id (String)
  • :content_md5 (String)
  • :tagging (required, Types::Tagging)

Returns:

See Also:



6220
6221
6222
6223
# File 'lib/aws-sdk-s3/client.rb', line 6220

def put_object_tagging(params = {}, options = {})
  req = build_request(:put_object_tagging, params)
  req.send_request(options)
end

#put_public_access_block(params = {}) ⇒ Struct

Creates or modifies the ‘PublicAccessBlock` configuration for an Amazon S3 bucket.

Examples:

Request syntax with placeholder values


resp = client.put_public_access_block({
  bucket: "BucketName", # required
  content_md5: "ContentMD5",
  public_access_block_configuration: { # required
    block_public_acls: false,
    ignore_public_acls: false,
    block_public_policy: false,
    restrict_public_buckets: false,
  },
})

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

Returns:

  • (Struct)

    Returns an empty response.

See Also:



6265
6266
6267
6268
# File 'lib/aws-sdk-s3/client.rb', line 6265

def put_public_access_block(params = {}, options = {})
  req = build_request(:put_public_access_block, params)
  req.send_request(options)
end

#restore_object(params = {}) ⇒ Types::RestoreObjectOutput

Restores an archived copy of an object back into Amazon S3

Examples:

Example: To restore an archived object


# The following example restores for one day an archived copy of an object back into Amazon S3 bucket.

resp = client.restore_object({
  bucket: "examplebucket", 
  key: "archivedobjectkey", 
  restore_request: {
    days: 1, 
    glacier_job_parameters: {
      tier: "Expedited", 
    }, 
  }, 
})

resp.to_h outputs the following:
{
}

Request syntax with placeholder values


resp = client.restore_object({
  bucket: "BucketName", # required
  key: "ObjectKey", # required
  version_id: "ObjectVersionId",
  restore_request: {
    days: 1,
    glacier_job_parameters: {
      tier: "Standard", # required, accepts Standard, Bulk, Expedited
    },
    type: "SELECT", # accepts SELECT
    tier: "Standard", # accepts Standard, Bulk, Expedited
    description: "Description",
    select_parameters: {
      input_serialization: { # required
        csv: {
          file_header_info: "USE", # accepts USE, IGNORE, NONE
          comments: "Comments",
          quote_escape_character: "QuoteEscapeCharacter",
          record_delimiter: "RecordDelimiter",
          field_delimiter: "FieldDelimiter",
          quote_character: "QuoteCharacter",
          allow_quoted_record_delimiter: false,
        },
        compression_type: "NONE", # accepts NONE, GZIP, BZIP2
        json: {
          type: "DOCUMENT", # accepts DOCUMENT, LINES
        },
        parquet: {
        },
      },
      expression_type: "SQL", # required, accepts SQL
      expression: "Expression", # required
      output_serialization: { # required
        csv: {
          quote_fields: "ALWAYS", # accepts ALWAYS, ASNEEDED
          quote_escape_character: "QuoteEscapeCharacter",
          record_delimiter: "RecordDelimiter",
          field_delimiter: "FieldDelimiter",
          quote_character: "QuoteCharacter",
        },
        json: {
          record_delimiter: "RecordDelimiter",
        },
      },
    },
    output_location: {
      s3: {
        bucket_name: "BucketName", # required
        prefix: "LocationPrefix", # required
        encryption: {
          encryption_type: "AES256", # required, accepts AES256, aws:kms
          kms_key_id: "SSEKMSKeyId",
          kms_context: "KMSContext",
        },
        canned_acl: "private", # accepts private, public-read, public-read-write, authenticated-read, aws-exec-read, bucket-owner-read, bucket-owner-full-control
        access_control_list: [
          {
            grantee: {
              display_name: "DisplayName",
              email_address: "EmailAddress",
              id: "ID",
              type: "CanonicalUser", # required, accepts CanonicalUser, AmazonCustomerByEmail, Group
              uri: "URI",
            },
            permission: "FULL_CONTROL", # accepts FULL_CONTROL, WRITE, WRITE_ACP, READ, READ_ACP
          },
        ],
        tagging: {
          tag_set: [ # required
            {
              key: "ObjectKey", # required
              value: "Value", # required
            },
          ],
        },
        user_metadata: [
          {
            name: "MetadataKey",
            value: "MetadataValue",
          },
        ],
        storage_class: "STANDARD", # accepts STANDARD, REDUCED_REDUNDANCY, STANDARD_IA, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER
      },
    },
  },
  request_payer: "requester", # accepts requester
})

Response structure


resp.request_charged #=> String, one of "requester"
resp.restore_output_path #=> String

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :bucket (required, String)
  • :key (required, String)
  • :version_id (String)
  • :restore_request (Types::RestoreRequest)

    Container for restore job parameters.

  • :request_payer (String)

    Confirms that the requester knows that she or he will be charged for the request. Bucket owners need not specify this parameter in their requests. Documentation on downloading objects from requester pays buckets can be found at docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html

Returns:

See Also:



6412
6413
6414
6415
# File 'lib/aws-sdk-s3/client.rb', line 6412

def restore_object(params = {}, options = {})
  req = build_request(:restore_object, params)
  req.send_request(options)
end

#select_object_content(params = {}) ⇒ Types::SelectObjectContentOutput

This operation filters the contents of an Amazon S3 object based on a simple Structured Query Language (SQL) statement. In the request, along with the SQL expression, you must also specify a data serialization format (JSON or CSV) of the object. Amazon S3 uses this to parse object data into records, and returns only records that match the specified SQL expression. You must also specify the data serialization format for the response.

Examples:

EventStream Operation Example


You can process event once it arrives immediately, or wait until
full response complete and iterate through eventstream enumerator.

To interact with event immediately, you need to register #select_object_content
with callbacks, callbacks can be register for specifc events or for all events,
callback for errors in the event stream is also available for register.

Callbacks can be passed in by `:event_stream_handler` option or within block
statement attached to #select_object_content call directly. Hybrid pattern of both
is also supported.

`:event_stream_handler` option takes in either Proc object or
EventStreams::SelectObjectContentEventStream object.

Usage pattern a): callbacks with a block attached to #select_object_content
  Example for registering callbacks for all event types and error event

  client.select_object_content( # params input# ) do |stream|

    stream.on_error_event do |event|
      # catch unmodeled error event in the stream
      raise event
      # => Aws::Errors::EventError
      # event.event_type => :error
      # event.error_code => String
      # event.error_message => String
    end

    stream.on_event do |event|
      # process all events arrive
      puts event.event_type
      ...
    end

  end

Usage pattern b): pass in `:event_stream_handler` for #select_object_content

  1) create a EventStreams::SelectObjectContentEventStream object
  Example for registering callbacks with specific events

    handler = Aws::S3::EventStreams::SelectObjectContentEventStream.new
    handler.on_records_event do |event|
      event # => Aws::S3::Types::Records
    end
    handler.on_stats_event do |event|
      event # => Aws::S3::Types::Stats
    end
    handler.on_progress_event do |event|
      event # => Aws::S3::Types::Progress
    end
    handler.on_cont_event do |event|
      event # => Aws::S3::Types::Cont
    end
    handler.on_end_event do |event|
      event # => Aws::S3::Types::End
    end

  client.select_object_content( # params input #, event_stream_handler: handler)

  2) use a Ruby Proc object
  Example for registering callbacks with specific events

  handler = Proc.new do |stream|
    stream.on_records_event do |event|
      event # => Aws::S3::Types::Records
    end
    stream.on_stats_event do |event|
      event # => Aws::S3::Types::Stats
    end
    stream.on_progress_event do |event|
      event # => Aws::S3::Types::Progress
    end
    stream.on_cont_event do |event|
      event # => Aws::S3::Types::Cont
    end
    stream.on_end_event do |event|
      event # => Aws::S3::Types::End
    end
  end

  client.select_object_content( # params input #, event_stream_handler: handler)

Usage pattern c): hybird pattern of a) and b)

    handler = Aws::S3::EventStreams::SelectObjectContentEventStream.new
    handler.on_records_event do |event|
      event # => Aws::S3::Types::Records
    end
    handler.on_stats_event do |event|
      event # => Aws::S3::Types::Stats
    end
    handler.on_progress_event do |event|
      event # => Aws::S3::Types::Progress
    end
    handler.on_cont_event do |event|
      event # => Aws::S3::Types::Cont
    end
    handler.on_end_event do |event|
      event # => Aws::S3::Types::End
    end

  client.select_object_content( # params input #, event_stream_handler: handler) do |stream|
    stream.on_error_event do |event|
      # catch unmodeled error event in the stream
      raise event
      # => Aws::Errors::EventError
      # event.event_type => :error
      # event.error_code => String
      # event.error_message => String
    end
  end

Besides above usage patterns for process events when they arrive immediately, you can also
iterate through events after response complete.

Events are available at resp.payload # => Enumerator
For parameter input example, please refer to following request syntax

Request syntax with placeholder values


resp = client.select_object_content({
  bucket: "BucketName", # required
  key: "ObjectKey", # required
  sse_customer_algorithm: "SSECustomerAlgorithm",
  sse_customer_key: "SSECustomerKey",
  sse_customer_key_md5: "SSECustomerKeyMD5",
  expression: "Expression", # required
  expression_type: "SQL", # required, accepts SQL
  request_progress: {
    enabled: false,
  },
  input_serialization: { # required
    csv: {
      file_header_info: "USE", # accepts USE, IGNORE, NONE
      comments: "Comments",
      quote_escape_character: "QuoteEscapeCharacter",
      record_delimiter: "RecordDelimiter",
      field_delimiter: "FieldDelimiter",
      quote_character: "QuoteCharacter",
      allow_quoted_record_delimiter: false,
    },
    compression_type: "NONE", # accepts NONE, GZIP, BZIP2
    json: {
      type: "DOCUMENT", # accepts DOCUMENT, LINES
    },
    parquet: {
    },
  },
  output_serialization: { # required
    csv: {
      quote_fields: "ALWAYS", # accepts ALWAYS, ASNEEDED
      quote_escape_character: "QuoteEscapeCharacter",
      record_delimiter: "RecordDelimiter",
      field_delimiter: "FieldDelimiter",
      quote_character: "QuoteCharacter",
    },
    json: {
      record_delimiter: "RecordDelimiter",
    },
  },
})

Response structure


All events are available at resp.payload:
resp.payload #=> Enumerator
resp.payload.event_types #=> [:records, :stats, :progress, :cont, :end]

For :records event available at #on_records_event callback and response eventstream enumerator:
event.payload #=> IO

For :stats event available at #on_stats_event callback and response eventstream enumerator:
event.details.bytes_scanned #=> Integer
event.details.bytes_processed #=> Integer
event.details.bytes_returned #=> Integer

For :progress event available at #on_progress_event callback and response eventstream enumerator:
event.details.bytes_scanned #=> Integer
event.details.bytes_processed #=> Integer
event.details.bytes_returned #=> Integer

For :cont event available at #on_cont_event callback and response eventstream enumerator:
 #=> EmptyStruct
For :end event available at #on_end_event callback and response eventstream enumerator:
 #=> EmptyStruct

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

Yields:

  • (event_stream_handler)

Returns:

See Also:



6669
6670
6671
6672
6673
6674
6675
6676
6677
6678
6679
6680
6681
6682
6683
6684
6685
6686
6687
6688
6689
6690
# File 'lib/aws-sdk-s3/client.rb', line 6669

def select_object_content(params = {}, options = {}, &block)
  params = params.dup
  event_stream_handler = case handler = params.delete(:event_stream_handler)
    when EventStreams::SelectObjectContentEventStream then handler
    when Proc then EventStreams::SelectObjectContentEventStream.new.tap(&handler)
    when nil then EventStreams::SelectObjectContentEventStream.new
    else
      msg = "expected :event_stream_handler to be a block or "\
        "instance of Aws::S3::EventStreams::SelectObjectContentEventStream"\
        ", got `#{handler.inspect}` instead"
      raise ArgumentError, msg
    end

  yield(event_stream_handler) if block_given?

  req = build_request(:select_object_content, params)

  req.context[:event_stream_handler] = event_stream_handler
  req.handlers.add(Aws::Binary::DecodeHandler, priority: 95)

  req.send_request(options, &block)
end

#upload_part(params = {}) ⇒ Types::UploadPartOutput

Uploads a part in a multipart upload.

Note: After you initiate multipart upload and upload one or more parts, you must either complete or abort multipart upload in order to stop getting charged for storage of the uploaded parts. Only after you either complete or abort multipart upload, Amazon S3 frees up the parts storage and stops charging you for the parts storage.

Examples:

Example: To upload a part


# The following example uploads part 1 of a multipart upload. The example specifies a file name for the part data. The
# Upload ID is same that is returned by the initiate multipart upload.

resp = client.upload_part({
  body: "fileToUpload", 
  bucket: "examplebucket", 
  key: "examplelargeobject", 
  part_number: 1, 
  upload_id: "xadcOB_7YPBOJuoFiQ9cz4P3Pe6FIZwO4f7wN93uHsNBEw97pl5eNwzExg0LAT2dUN91cOmrEQHDsP3WA60CEg--", 
})

resp.to_h outputs the following:
{
  etag: "\"d8c2eafd90c266e19ab9dcacc479f8af\"", 
}

Request syntax with placeholder values


resp = client.upload_part({
  body: source_file,
  bucket: "BucketName", # required
  content_length: 1,
  content_md5: "ContentMD5",
  key: "ObjectKey", # required
  part_number: 1, # required
  upload_id: "MultipartUploadId", # required
  sse_customer_algorithm: "SSECustomerAlgorithm",
  sse_customer_key: "SSECustomerKey",
  sse_customer_key_md5: "SSECustomerKeyMD5",
  request_payer: "requester", # accepts requester
})

Response structure


resp.server_side_encryption #=> String, one of "AES256", "aws:kms"
resp.etag #=> String
resp.sse_customer_algorithm #=> String
resp.sse_customer_key_md5 #=> String
resp.ssekms_key_id #=> String
resp.request_charged #=> String, one of "requester"

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :body (String, IO)

    Object data.

  • :bucket (required, String)

    Name of the bucket to which the multipart upload was initiated.

  • :content_length (Integer)

    Size of the body in bytes. This parameter is useful when the size of the body cannot be determined automatically.

  • :content_md5 (String)

    The base64-encoded 128-bit MD5 digest of the part data.

  • :key (required, String)

    Object key for which the multipart upload was initiated.

  • :part_number (required, Integer)

    Part number of part being uploaded. This is a positive integer between 1 and 10,000.

  • :upload_id (required, String)

    Upload ID identifying the multipart upload whose part is being uploaded.

  • :sse_customer_algorithm (String)

    Specifies the algorithm to use to when encrypting the object (e.g., AES256).

  • :sse_customer_key (String)

    Specifies the customer-provided encryption key for Amazon S3 to use in encrypting data. This value is used to store the object and then it is discarded; Amazon does not store the encryption key. The key must be appropriate for use with the algorithm specified in the x-amz-server-side​-encryption​-customer-algorithm header. This must be the same encryption key specified in the initiate multipart upload request.

  • :sse_customer_key_md5 (String)

    Specifies the 128-bit MD5 digest of the encryption key according to RFC 1321. Amazon S3 uses this header for a message integrity check to ensure the encryption key was transmitted without error.

  • :request_payer (String)

    Confirms that the requester knows that she or he will be charged for the request. Bucket owners need not specify this parameter in their requests. Documentation on downloading objects from requester pays buckets can be found at docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html

Returns:

See Also:



6806
6807
6808
6809
# File 'lib/aws-sdk-s3/client.rb', line 6806

def upload_part(params = {}, options = {})
  req = build_request(:upload_part, params)
  req.send_request(options)
end

#upload_part_copy(params = {}) ⇒ Types::UploadPartCopyOutput

Uploads a part by copying data from an existing object as data source.

Examples:

Example: To upload a part by copying byte range from an existing object as data source


# The following example uploads a part of a multipart upload by copying a specified byte range from an existing object as
# data source.

resp = client.upload_part_copy({
  bucket: "examplebucket", 
  copy_source: "/bucketname/sourceobjectkey", 
  copy_source_range: "bytes=1-100000", 
  key: "examplelargeobject", 
  part_number: 2, 
  upload_id: "exampleuoh_10OhKhT7YukE9bjzTPRiuaCotmZM_pFngJFir9OZNrSr5cWa3cq3LZSUsfjI4FI7PkP91We7Nrw--", 
})

resp.to_h outputs the following:
{
  copy_part_result: {
    etag: "\"65d16d19e65a7508a51f043180edcc36\"", 
    last_modified: Time.parse("2016-12-29T21:44:28.000Z"), 
  }, 
}

Example: To upload a part by copying data from an existing object as data source


# The following example uploads a part of a multipart upload by copying data from an existing object as data source.

resp = client.upload_part_copy({
  bucket: "examplebucket", 
  copy_source: "/bucketname/sourceobjectkey", 
  key: "examplelargeobject", 
  part_number: 1, 
  upload_id: "exampleuoh_10OhKhT7YukE9bjzTPRiuaCotmZM_pFngJFir9OZNrSr5cWa3cq3LZSUsfjI4FI7PkP91We7Nrw--", 
})

resp.to_h outputs the following:
{
  copy_part_result: {
    etag: "\"b0c6f0e7e054ab8fa2536a2677f8734d\"", 
    last_modified: Time.parse("2016-12-29T21:24:43.000Z"), 
  }, 
}

Request syntax with placeholder values


resp = client.upload_part_copy({
  bucket: "BucketName", # required
  copy_source: "CopySource", # required
  copy_source_if_match: "CopySourceIfMatch",
  copy_source_if_modified_since: Time.now,
  copy_source_if_none_match: "CopySourceIfNoneMatch",
  copy_source_if_unmodified_since: Time.now,
  copy_source_range: "CopySourceRange",
  key: "ObjectKey", # required
  part_number: 1, # required
  upload_id: "MultipartUploadId", # required
  sse_customer_algorithm: "SSECustomerAlgorithm",
  sse_customer_key: "SSECustomerKey",
  sse_customer_key_md5: "SSECustomerKeyMD5",
  copy_source_sse_customer_algorithm: "CopySourceSSECustomerAlgorithm",
  copy_source_sse_customer_key: "CopySourceSSECustomerKey",
  copy_source_sse_customer_key_md5: "CopySourceSSECustomerKeyMD5",
  request_payer: "requester", # accepts requester
})

Response structure


resp.copy_source_version_id #=> String
resp.copy_part_result.etag #=> String
resp.copy_part_result.last_modified #=> Time
resp.server_side_encryption #=> String, one of "AES256", "aws:kms"
resp.sse_customer_algorithm #=> String
resp.sse_customer_key_md5 #=> String
resp.ssekms_key_id #=> String
resp.request_charged #=> String, one of "requester"

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :bucket (required, String)
  • :copy_source (required, String)

    The name of the source bucket and key name of the source object, separated by a slash (/). Must be URL-encoded.

  • :copy_source_if_match (String)

    Copies the object if its entity tag (ETag) matches the specified tag.

  • :copy_source_if_modified_since (Time, DateTime, Date, Integer, String)

    Copies the object if it has been modified since the specified time.

  • :copy_source_if_none_match (String)

    Copies the object if its entity tag (ETag) is different than the specified ETag.

  • :copy_source_if_unmodified_since (Time, DateTime, Date, Integer, String)

    Copies the object if it hasn’t been modified since the specified time.

  • :copy_source_range (String)

    The range of bytes to copy from the source object. The range value must use the form bytes=first-last, where the first and last are the zero-based byte offsets to copy. For example, bytes=0-9 indicates that you want to copy the first ten bytes of the source. You can copy a range only if the source object is greater than 5 MB.

  • :key (required, String)
  • :part_number (required, Integer)

    Part number of part being copied. This is a positive integer between 1 and 10,000.

  • :upload_id (required, String)

    Upload ID identifying the multipart upload whose part is being copied.

  • :sse_customer_algorithm (String)

    Specifies the algorithm to use to when encrypting the object (e.g., AES256).

  • :sse_customer_key (String)

    Specifies the customer-provided encryption key for Amazon S3 to use in encrypting data. This value is used to store the object and then it is discarded; Amazon does not store the encryption key. The key must be appropriate for use with the algorithm specified in the x-amz-server-side​-encryption​-customer-algorithm header. This must be the same encryption key specified in the initiate multipart upload request.

  • :sse_customer_key_md5 (String)

    Specifies the 128-bit MD5 digest of the encryption key according to RFC 1321. Amazon S3 uses this header for a message integrity check to ensure the encryption key was transmitted without error.

  • :copy_source_sse_customer_algorithm (String)

    Specifies the algorithm to use when decrypting the source object (e.g., AES256).

  • :copy_source_sse_customer_key (String)

    Specifies the customer-provided encryption key for Amazon S3 to use to decrypt the source object. The encryption key provided in this header must be one that was used when the source object was created.

  • :copy_source_sse_customer_key_md5 (String)

    Specifies the 128-bit MD5 digest of the encryption key according to RFC 1321. Amazon S3 uses this header for a message integrity check to ensure the encryption key was transmitted without error.

  • :request_payer (String)

    Confirms that the requester knows that she or he will be charged for the request. Bucket owners need not specify this parameter in their requests. Documentation on downloading objects from requester pays buckets can be found at docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html

Returns:

See Also:



6978
6979
6980
6981
# File 'lib/aws-sdk-s3/client.rb', line 6978

def upload_part_copy(params = {}, options = {})
  req = build_request(:upload_part_copy, params)
  req.send_request(options)
end

#wait_until(waiter_name, params = {}, options = {}) {|w.waiter| ... } ⇒ Boolean

Polls an API operation until a resource enters a desired state.

## Basic Usage

A waiter will call an API operation until:

  • It is successful

  • It enters a terminal state

  • It makes the maximum number of attempts

In between attempts, the waiter will sleep.

# polls in a loop, sleeping between attempts
client.waiter_until(waiter_name, params)

## Configuration

You can configure the maximum number of polling attempts, and the delay (in seconds) between each polling attempt. You can pass configuration as the final arguments hash.

# poll for ~25 seconds
client.wait_until(waiter_name, params, {
  max_attempts: 5,
  delay: 5,
})

## Callbacks

You can be notified before each polling attempt and before each delay. If you throw ‘:success` or `:failure` from these callbacks, it will terminate the waiter.

started_at = Time.now
client.wait_until(waiter_name, params, {

  # disable max attempts
  max_attempts: nil,

  # poll for 1 hour, instead of a number of attempts
  before_wait: -> (attempts, response) do
    throw :failure if Time.now - started_at > 3600
  end
})

## Handling Errors

When a waiter is unsuccessful, it will raise an error. All of the failure errors extend from Waiters::Errors::WaiterFailed.

begin
  client.wait_until(...)
rescue Aws::Waiters::Errors::WaiterFailed
  # resource did not enter the desired state in time
end

## Valid Waiters

The following table lists the valid waiter names, the operations they call, and the default ‘:delay` and `:max_attempts` values.

| waiter_name | params | :delay | :max_attempts | | —————– | ————– | ——– | ————- | | bucket_exists | #head_bucket | 5 | 20 | | bucket_not_exists | #head_bucket | 5 | 20 | | object_exists | #head_object | 5 | 20 | | object_not_exists | #head_object | 5 | 20 |

Parameters:

  • waiter_name (Symbol)
  • params (Hash) (defaults to: {})

    ({})

  • options (Hash) (defaults to: {})

    ({})

Options Hash (options):

  • :max_attempts (Integer)
  • :delay (Integer)
  • :before_attempt (Proc)
  • :before_wait (Proc)

Yields:

  • (w.waiter)

Returns:

  • (Boolean)

    Returns ‘true` if the waiter was successful.

Raises:

  • (Errors::FailureStateError)

    Raised when the waiter terminates because the waiter has entered a state that it will not transition out of, preventing success.

  • (Errors::TooManyAttemptsError)

    Raised when the configured maximum number of attempts have been made, and the waiter is not yet successful.

  • (Errors::UnexpectedError)

    Raised when an error is encounted while polling for a resource that is not expected.

  • (Errors::NoSuchWaiterError)

    Raised when you request to wait for an unknown state.



7091
7092
7093
7094
7095
# File 'lib/aws-sdk-s3/client.rb', line 7091

def wait_until(waiter_name, params = {}, options = {})
  w = waiter(waiter_name, options)
  yield(w.waiter) if block_given? # deprecated
  w.wait(params)
end

#waiter_namesObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Deprecated.


7099
7100
7101
# File 'lib/aws-sdk-s3/client.rb', line 7099

def waiter_names
  waiters.keys
end