Class: Aws::S3::Client

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

Overview

An API client for S3. To construct a client, you need to configure a `:region` and `:credentials`.

client = Aws::S3::Client.new(
  region: region_name,
  credentials: credentials,
  # ...
)

For details on configuring region and credentials see the [developer guide](/sdk-for-ruby/v3/developer-guide/setup-config.html).

See #initialize for a full list of supported configuration options.

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::SharedCredentials` - Used for loading static credentials from a shared file, such as `~/.aws/config`.

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

    • `Aws::AssumeRoleWebIdentityCredentials` - Used when you need to assume a role after providing credentials via the web.

    • `Aws::SSOCredentials` - Used for loading credentials from AWS SSO using an access token generated from `aws login`.

    • `Aws::ProcessCredentials` - Used for loading credentials from a process that outputs to stdout.

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

    • `Aws::ECSCredentials` - Used for loading credentials from instances running in ECS.

    • `Aws::CognitoIdentityCredentials` - Used for loading credentials from the Cognito Identity service.

    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/ECS IMDS instance profile - When used by default, the timeouts are very aggressive. Construct and pass an instance of `Aws::InstanceProfileCredentails` or `Aws::ECSCredentials` 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 searched 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`.

  • :adaptive_retry_wait_to_fill (Boolean) — default: true

    Used only in `adaptive` retry mode. When true, the request will sleep until there is sufficent client side capacity to retry the request. When false, the request will raise a `RetryCapacityNotAvailableError` and will not retry instead of sleeping.

  • :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_host (String) — default: "127.0.0.1"

    Allows you to specify the DNS hostname or IPv4 or IPv6 address that the client side monitoring agent is running on, where client metrics will be published via UDP.

  • :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 and sent in the Content Md5 header for :put_object and :upload_part. When `false`, MD5 checksums will not be computed for these operations. Checksums are still computed for operations requiring 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.

  • :correct_clock_skew (Boolean) — default: true

    Used only in `standard` and adaptive retry modes. Specifies whether to apply a clock skew correction and retry requests with skewed client clocks.

  • :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 or custom endpoints. This should be a valid 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.

  • :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.

  • :input_event_stream_handler (Proc)

    When an EventStream or Proc object is provided, it can be used for sending events for the event stream.

  • :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.

  • :max_attempts (Integer) — default: 3

    An integer representing the maximum number attempts that will be made for a single request, including the initial attempt. For example, setting this value to 5 will result in a request being retried up to 4 times. Used in `standard` and `adaptive` retry modes.

  • :output_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.

  • :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_backoff (Proc)

    A proc or lambda used for backoff. Defaults to 2**retries * retry_base_delay. This option is only used in the `legacy` retry mode.

  • :retry_base_delay (Float) — default: 0.3

    The base delay in seconds used by the default backoff function. This option is only used in the `legacy` retry mode.

  • :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. This option is only used in the `legacy` retry mode.

    @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, auth errors, endpoint discovery, and errors from expired credentials. This option is only used in the `legacy` retry mode.

  • :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. This option is only used in the `legacy` retry mode.

  • :retry_mode (String) — default: "legacy"

    Specifies which retry algorithm to use. Values are:

    • `legacy` - The pre-existing retry behavior. This is default value if no retry mode is provided.

    • `standard` - A standardized set of retry rules across the AWS SDKs. This includes support for retry quotas, which limit the number of unsuccessful retries a client can make.

    • `adaptive` - An experimental retry mode that includes all the functionality of `standard` mode along with automatic client side throttling. This is a provisional mode that may change behavior in the future.

  • :s3_disable_multiregion_access_points (Boolean) — default: false

    When set to `false` this will option will raise errors when multi-region access point ARNs are used. Multi-region access points can potentially result in cross region requests.

  • :s3_us_east_1_regional_endpoint (String) — default: "legacy"

    Pass in `regional` to enable the `us-east-1` regional endpoint. Defaults to `legacy` mode which uses the global endpoint.

  • :s3_use_arn_region (Boolean) — default: true

    For S3 ARNs passed into the `:bucket` parameter, this option will use the region in the ARN, allowing for cross-region requests to be made. Set to `false` to use the client's region instead.

  • :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.

  • :http_proxy (URI::HTTP, String)

    A proxy to send requests through. Formatted like 'proxy.com:123'.

  • :http_open_timeout (Float) — default: 15

    The number of seconds to wait when opening a HTTP session before raising a `Timeout::Error`.

  • :http_read_timeout (Integer) — default: 60

    The default number of seconds to wait for response data. This value can safely be set per-request on the session.

  • :http_idle_timeout (Float) — default: 5

    The number of seconds a connection is allowed to sit idle before it is considered stale. Stale connections are closed and removed from the pool before making a request.

  • :http_continue_timeout (Float) — default: 1

    The number of seconds to wait for a 100-continue response before sending the request body. This option has no effect unless the request has “Expect” header set to “100-continue”. Defaults to `nil` which disables this behaviour. This value can safely be set per request on the session.

  • :http_wire_trace (Boolean) — default: false

    When `true`, HTTP debug output will be sent to the `:logger`.

  • :ssl_verify_peer (Boolean) — default: true

    When `true`, SSL peer certificates are verified when establishing a connection.

  • :ssl_ca_bundle (String)

    Full path to the SSL certificate authority bundle file that should be used when verifying peer certificates. If you do not pass `:ssl_ca_bundle` or `:ssl_ca_directory` the the system default will be used if available.

  • :ssl_ca_directory (String)

    Full path of the directory that contains the unbundled SSL certificate authority files for verifying peer certificates. If you do not pass `:ssl_ca_bundle` or `:ssl_ca_directory` the the system default will be used if available.


412
413
414
# File 'lib/aws-sdk-s3/client.rb', line 412

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.


14196
14197
14198
# File 'lib/aws-sdk-s3/client.rb', line 14196

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.


14199
14200
14201
# File 'lib/aws-sdk-s3/client.rb', line 14199

def errors_module
  Errors
end

Instance Method Details

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

This action aborts a multipart upload. After a multipart upload is aborted, no additional parts can be uploaded using that upload ID. The storage consumed by any previously uploaded parts will be freed. However, if any part uploads are currently in progress, those part uploads might or might not succeed. As a result, it might be necessary to abort a given multipart upload multiple times in order to completely free all storage consumed by all parts.

To verify that all parts have been removed, so you don't get charged for the part storage, you should call the [ListParts] action and ensure that the parts list is empty.

For information about permissions required to use the multipart upload, see [Multipart Upload and Permissions].

The following operations are related to `AbortMultipartUpload`:

  • CreateMultipartUpload][3
  • UploadPart][4
  • CompleteMultipartUpload][5
  • ListParts][1
  • ListMultipartUploads][6

[1]: docs.aws.amazon.com/AmazonS3/latest/API/API_ListParts.html [2]: docs.aws.amazon.com/AmazonS3/latest/dev/mpuAndPermissions.html [3]: docs.aws.amazon.com/AmazonS3/latest/API/API_CreateMultipartUpload.html [4]: docs.aws.amazon.com/AmazonS3/latest/API/API_UploadPart.html [5]: docs.aws.amazon.com/AmazonS3/latest/API/API_CompleteMultipartUpload.html [6]: docs.aws.amazon.com/AmazonS3/latest/API/API_ListMultipartUploads.html

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
  expected_bucket_owner: "AccountId",
})

Response structure


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

Parameters:

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

    ({})

Options Hash (params):

  • :bucket (required, String)

    The bucket name to which the upload was taking place.

    When using this action with an access point, you must direct requests to the access point hostname. The access point hostname takes the form AccessPointName-AccountId.s3-accesspoint.Region.amazonaws.com. When using this action with an access point through the Amazon Web Services SDKs, you provide the access point ARN in place of the bucket name. For more information about access point ARNs, see [Using access points] in the *Amazon S3 User Guide*.

    When using this action with Amazon S3 on Outposts, you must direct requests to the S3 on Outposts hostname. The S3 on Outposts hostname takes the form AccessPointName-AccountId.outpostID.s3-outposts.Region.amazonaws.com. When using this action using S3 on Outposts through the Amazon Web Services SDKs, you provide the Outposts bucket ARN in place of the bucket name. For more information about S3 on Outposts ARNs, see

    Using S3 on Outposts][2

    in the *Amazon S3 User Guide*.

    [1]: docs.aws.amazon.com/AmazonS3/latest/userguide/using-access-points.html [2]: docs.aws.amazon.com/AmazonS3/latest/userguide/S3onOutposts.html

  • :key (required, String)

    Key of the object for which the multipart upload was initiated.

  • :upload_id (required, String)

    Upload ID that identifies the multipart upload.

  • :request_payer (String)

    Confirms that the requester knows that they will be charged for the request. Bucket owners need not specify this parameter in their requests. For information about downloading objects from requester pays buckets, see [Downloading Objects in Requestor Pays Buckets] in the *Amazon S3 User Guide*.

    [1]: docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html

  • :expected_bucket_owner (String)

    The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP `403 (Access Denied)` error.

Returns:

See Also:


538
539
540
541
# File 'lib/aws-sdk-s3/client.rb', line 538

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: {})

14055
14056
14057
14058
14059
14060
14061
14062
14063
14064
14065
14066
# File 'lib/aws-sdk-s3/client.rb', line 14055

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.103.0'
  Seahorse::Client::Request.new(handlers, context)
end

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

Completes a multipart upload by assembling previously uploaded parts.

You first initiate the multipart upload and then upload all parts using the [UploadPart] operation. After successfully uploading all relevant parts of an upload, you call this action to complete the upload. Upon receiving this request, Amazon S3 concatenates all the parts in ascending order by part number to create a new object. In the Complete Multipart Upload request, you must provide the parts list. You must ensure that the parts list is complete. This action concatenates the parts that you provide in the list. For each part in the list, you must provide the part number and the `ETag` value, returned after that part was uploaded.

Processing of a Complete Multipart Upload request could take several minutes to complete. After Amazon S3 begins processing the request, it sends an HTTP response header that specifies a 200 OK response. While processing is in progress, Amazon S3 periodically sends white space characters to keep the connection from timing out. Because a request could fail after the initial 200 OK response has been sent, it is important that you check the response body to determine whether the request succeeded.

Note that if `CompleteMultipartUpload` fails, applications should be prepared to retry the failed requests. For more information, see [Amazon S3 Error Best Practices].

For more information about multipart uploads, see [Uploading Objects Using Multipart Upload].

For information about permissions required to use the multipart upload API, see [Multipart Upload and Permissions].

`CompleteMultipartUpload` has the following special errors:

  • Error code: `EntityTooSmall`

    • Description: Your proposed upload is smaller than the minimum allowed object size. Each part must be at least 5 MB in size, except the last part.

    • 400 Bad Request

  • Error code: `InvalidPart`

    • Description: One or more of the specified parts could not be found. The part might not have been uploaded, or the specified entity tag might not have matched the part's entity tag.

    • 400 Bad Request

  • Error code: `InvalidPartOrder`

    • Description: The list of parts was not in ascending order. The parts list must be specified in order by part number.

    • 400 Bad Request

  • Error code: `NoSuchUpload`

    • Description: The specified multipart upload does not exist. The upload ID might be invalid, or the multipart upload might have been aborted or completed.

    • 404 Not Found

The following operations are related to `CompleteMultipartUpload`:

  • CreateMultipartUpload][5
  • UploadPart][1
  • AbortMultipartUpload][6
  • ListParts][7
  • ListMultipartUploads][8

[1]: docs.aws.amazon.com/AmazonS3/latest/API/API_UploadPart.html [2]: docs.aws.amazon.com/AmazonS3/latest/dev/ErrorBestPractices.html [3]: docs.aws.amazon.com/AmazonS3/latest/dev/uploadobjusingmpu.html [4]: docs.aws.amazon.com/AmazonS3/latest/dev/mpuAndPermissions.html [5]: docs.aws.amazon.com/AmazonS3/latest/API/API_CreateMultipartUpload.html [6]: docs.aws.amazon.com/AmazonS3/latest/API/API_AbortMultipartUpload.html [7]: docs.aws.amazon.com/AmazonS3/latest/API/API_ListParts.html [8]: docs.aws.amazon.com/AmazonS3/latest/API/API_ListMultipartUploads.html

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.<Region>.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
  expected_bucket_owner: "AccountId",
})

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.bucket_key_enabled #=> Boolean
resp.request_charged #=> String, one of "requester"

Parameters:

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

    ({})

Options Hash (params):

  • :bucket (required, String)

    Name of the bucket to which the multipart upload was initiated.

    When using this action with an access point, you must direct requests to the access point hostname. The access point hostname takes the form AccessPointName-AccountId.s3-accesspoint.Region.amazonaws.com. When using this action with an access point through the Amazon Web Services SDKs, you provide the access point ARN in place of the bucket name. For more information about access point ARNs, see [Using access points] in the *Amazon S3 User Guide*.

    When using this action with Amazon S3 on Outposts, you must direct requests to the S3 on Outposts hostname. The S3 on Outposts hostname takes the form AccessPointName-AccountId.outpostID.s3-outposts.Region.amazonaws.com. When using this action using S3 on Outposts through the Amazon Web Services SDKs, you provide the Outposts bucket ARN in place of the bucket name. For more information about S3 on Outposts ARNs, see

    Using S3 on Outposts][2

    in the *Amazon S3 User Guide*.

    [1]: docs.aws.amazon.com/AmazonS3/latest/userguide/using-access-points.html [2]: docs.aws.amazon.com/AmazonS3/latest/userguide/S3onOutposts.html

  • :key (required, String)

    Object key for which the multipart upload was initiated.

  • :multipart_upload (Types::CompletedMultipartUpload)

    The container for the multipart upload request information.

  • :upload_id (required, String)

    ID for the initiated multipart upload.

  • :request_payer (String)

    Confirms that the requester knows that they will be charged for the request. Bucket owners need not specify this parameter in their requests. For information about downloading objects from requester pays buckets, see [Downloading Objects in Requestor Pays Buckets] in the *Amazon S3 User Guide*.

    [1]: docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html

  • :expected_bucket_owner (String)

    The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP `403 (Access Denied)` error.

Returns:

See Also:


760
761
762
763
# File 'lib/aws-sdk-s3/client.rb', line 760

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.

<note markdown=“1”> You can store individual objects of up to 5 TB in Amazon S3. You create a copy of your object up to 5 GB in size in a single atomic action using this API. However, to copy an object greater than 5 GB, you must use the multipart upload Upload Part - Copy API. For more information, see [Copy Object Using the REST Multipart Upload API].

</note>

All copy requests must be authenticated. Additionally, you must have read access to the source object and write access to the destination bucket. For more information, see [REST Authentication]. Both the Region that you want to copy the object from and the Region that you want to copy the object to must be enabled for your account.

A copy request might return an error when Amazon S3 receives the copy request or while Amazon S3 is copying the files. If the error occurs before the copy action starts, you receive a standard Amazon S3 error. If the error occurs during the copy operation, the error response is embedded in the `200 OK` response. This means that a `200 OK` response can contain either a success or an error. Design your application to parse the contents of the response and handle it appropriately.

If the copy is successful, you receive a response with information about the copied object.

<note markdown=“1”> If the request is an HTTP 1.1 request, the response is chunk encoded. If it were not, it would not contain the content-length, and you would need to read the entire body.

</note>

The copy request charge is based on the storage class and Region that you specify for the destination object. For pricing information, see [Amazon S3 pricing].

Amazon S3 transfer acceleration does not support cross-Region copies. If you request a cross-Region copy using a transfer acceleration endpoint, you get a 400 `Bad Request` error. For more information, see [Transfer Acceleration].

Metadata

When copying an object, you can preserve all metadata (default) or specify new metadata. However, the ACL is not preserved and is set to private for the user making the request. To override the default ACL setting, specify a new ACL when generating a copy request. For more information, see [Using ACLs].

To specify whether you want the object metadata copied from the source object or replaced with metadata provided in the request, you can optionally add the `x-amz-metadata-directive` header. When you grant permissions, you can use the `s3:x-amz-metadata-directive` condition key to enforce certain metadata behavior when objects are uploaded. For more information, see [Specifying Conditions in a Policy] in the *Amazon S3 User Guide*. For a complete list of Amazon S3-specific condition keys, see [Actions, Resources, and Condition Keys for Amazon S3].

x-amz-copy-source-if Headers

To only copy an object under certain conditions, such as whether the `Etag` matches or whether the object was modified before or after a specified date, use the following request parameters:

  • `x-amz-copy-source-if-match`

  • `x-amz-copy-source-if-none-match`

  • `x-amz-copy-source-if-unmodified-since`

  • `x-amz-copy-source-if-modified-since`

If both the `x-amz-copy-source-if-match` and `x-amz-copy-source-if-unmodified-since` headers are present in the request and evaluate as follows, Amazon S3 returns `200 OK` and copies the data:

  • `x-amz-copy-source-if-match` condition evaluates to true

  • `x-amz-copy-source-if-unmodified-since` condition evaluates to false

If both the `x-amz-copy-source-if-none-match` and `x-amz-copy-source-if-modified-since` headers are present in the request and evaluate as follows, Amazon S3 returns the `412 Precondition Failed` response code:

  • `x-amz-copy-source-if-none-match` condition evaluates to false

  • `x-amz-copy-source-if-modified-since` condition evaluates to true

<note markdown=“1”> All headers with the `x-amz-` prefix, including `x-amz-copy-source`, must be signed.

</note>

**Server-side encryption**

When you perform a CopyObject operation, you can optionally use the appropriate encryption-related headers to encrypt the object using server-side encryption with Amazon Web Services managed encryption keys (SSE-S3 or SSE-KMS) or a customer-provided encryption key. With server-side encryption, Amazon S3 encrypts your data as it writes it to disks in its data centers and decrypts the data when you access it. For more information about server-side encryption, see [Using Server-Side Encryption].

If a target object uses SSE-KMS, you can enable an S3 Bucket Key for the object. For more information, see [Amazon S3 Bucket Keys] in the *Amazon S3 User Guide*.

**Access Control List (ACL)-Specific Request Headers**

When copying an object, you can optionally use headers to grant ACL-based permissions. By default, all objects are private. Only the owner has full access control. When adding a new object, you can grant permissions to individual Amazon Web Services accounts or to predefined groups defined by Amazon S3. These permissions are then added to the ACL on the object. For more information, see [Access Control List (ACL) Overview] and [Managing ACLs Using the REST API].

**Storage Class Options**

You can use the `CopyObject` action to change the storage class of an object that is already stored in Amazon S3 using the `StorageClass` parameter. For more information, see [Storage Classes] in the *Amazon S3 User Guide*.

Versioning

By default, `x-amz-copy-source` identifies the current version of an object to copy. If the current version is a delete marker, Amazon S3 behaves as if the object was deleted. To copy a different version, use the `versionId` subresource.

If you enable versioning on the target bucket, Amazon S3 generates a unique version ID for the object being copied. This version ID is different from the version ID of the source object. Amazon S3 returns the version ID of the copied object in the `x-amz-version-id` response header in the response.

If you do not enable versioning or suspend it on the target bucket, the version ID that Amazon S3 generates is always null.

If the source object's storage class is GLACIER, you must restore a copy of this object before you can use it as a source object for the copy operation. For more information, see [RestoreObject].

The following operations are related to `CopyObject`:

  • PutObject][14
  • GetObject][15

For more information, see [Copying Objects].

[1]: docs.aws.amazon.com/AmazonS3/latest/dev/CopyingObjctsUsingRESTMPUapi.html [2]: docs.aws.amazon.com/AmazonS3/latest/dev/RESTAuthentication.html [3]: aws.amazon.com/s3/pricing/ [4]: docs.aws.amazon.com/AmazonS3/latest/dev/transfer-acceleration.html [5]: docs.aws.amazon.com/AmazonS3/latest/dev/S3_ACLs_UsingACLs.html [6]: docs.aws.amazon.com/AmazonS3/latest/dev/amazon-s3-policy-keys.html [7]: docs.aws.amazon.com/AmazonS3/latest/dev/list_amazons3.html [8]: docs.aws.amazon.com/AmazonS3/latest/dev/serv-side-encryption.html [9]: docs.aws.amazon.com/AmazonS3/latest/dev/bucket-key.html [10]: docs.aws.amazon.com/AmazonS3/latest/dev/acl-overview.html [11]: docs.aws.amazon.com/AmazonS3/latest/dev/acl-using-rest-api.html [12]: docs.aws.amazon.com/AmazonS3/latest/dev/storage-class-intro.html [13]: docs.aws.amazon.com/AmazonS3/latest/API/API_RestoreObject.html [14]: docs.aws.amazon.com/AmazonS3/latest/API/API_PutObject.html [15]: docs.aws.amazon.com/AmazonS3/latest/API/API_GetObject.html [16]: docs.aws.amazon.com/AmazonS3/latest/dev/CopyingObjectsExamples.html

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, DEEP_ARCHIVE, OUTPOSTS
  website_redirect_location: "WebsiteRedirectLocation",
  sse_customer_algorithm: "SSECustomerAlgorithm",
  sse_customer_key: "SSECustomerKey",
  sse_customer_key_md5: "SSECustomerKeyMD5",
  ssekms_key_id: "SSEKMSKeyId",
  ssekms_encryption_context: "SSEKMSEncryptionContext",
  bucket_key_enabled: false,
  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
  expected_bucket_owner: "AccountId",
  expected_source_bucket_owner: "AccountId",
})

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.ssekms_encryption_context #=> String
resp.bucket_key_enabled #=> Boolean
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.

    This action is not supported by Amazon S3 on Outposts.

  • :bucket (required, String)

    The name of the destination bucket.

    When using this action with an access point, you must direct requests to the access point hostname. The access point hostname takes the form AccessPointName-AccountId.s3-accesspoint.Region.amazonaws.com. When using this action with an access point through the Amazon Web Services SDKs, you provide the access point ARN in place of the bucket name. For more information about access point ARNs, see [Using access points] in the *Amazon S3 User Guide*.

    When using this action with Amazon S3 on Outposts, you must direct requests to the S3 on Outposts hostname. The S3 on Outposts hostname takes the form AccessPointName-AccountId.outpostID.s3-outposts.Region.amazonaws.com. When using this action using S3 on Outposts through the Amazon Web Services SDKs, you provide the Outposts bucket ARN in place of the bucket name. For more information about S3 on Outposts ARNs, see

    Using S3 on Outposts][2

    in the *Amazon S3 User Guide*.

    [1]: docs.aws.amazon.com/AmazonS3/latest/userguide/using-access-points.html [2]: docs.aws.amazon.com/AmazonS3/latest/userguide/S3onOutposts.html

  • :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)

    Specifies the source object for the copy operation. You specify the value in one of two formats, depending on whether you want to access the source object through an [access point]:

    • For objects not accessed through an access point, specify the name of the source bucket and the key of the source object, separated by a slash (/). For example, to copy the object `reports/january.pdf` from the bucket `awsexamplebucket`, use `awsexamplebucket/reports/january.pdf`. The value must be URL encoded.

    • For objects accessed through access points, specify the Amazon Resource Name (ARN) of the object as accessed through the access point, in the format `arn:aws:s3:<Region>:<account-id>:accesspoint/<access-point-name>/object/<key>`. For example, to copy the object `reports/january.pdf` through access point `my-access-point` owned by account `123456789012` in Region `us-west-2`, use the URL encoding of `arn:aws:s3:us-west-2:123456789012:accesspoint/my-access-point/object/reports/january.pdf`. The value must be URL encoded.

      <note markdown=“1”> Amazon S3 supports copy operations using access points only when the source and destination buckets are in the same Amazon Web Services Region.

      </note>
      

      Alternatively, for objects accessed through Amazon S3 on Outposts, specify the ARN of the object as accessed in the format `arn:aws:s3-outposts:<Region>:<account-id>:outpost/<outpost-id>/object/<key>`. For example, to copy the object `reports/january.pdf` through outpost `my-outpost` owned by account `123456789012` in Region `us-west-2`, use the URL encoding of `arn:aws:s3-outposts:us-west-2:123456789012:outpost/my-outpost/object/reports/january.pdf`. The value must be URL encoded.

    To copy a specific version of an object, append `?versionId=<version-id>` to the value (for example, `awsexamplebucket/reports/january.pdf?versionId=QUpfdndhfd8438MNFDN93jdnJFkdmqnh893`). If you don't specify a version ID, Amazon S3 copies the latest version of the source object.

    [1]: docs.aws.amazon.com/AmazonS3/latest/userguide/access-points.html

  • :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.

    This action is not supported by Amazon S3 on Outposts.

  • :grant_read (String)

    Allows grantee to read the object data and its metadata.

    This action is not supported by Amazon S3 on Outposts.

  • :grant_read_acp (String)

    Allows grantee to read the object ACL.

    This action is not supported by Amazon S3 on Outposts.

  • :grant_write_acp (String)

    Allows grantee to write the ACL for the applicable object.

    This action is not supported by Amazon S3 on Outposts.

  • :key (required, String)

    The key of the destination object.

  • :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 Amazon S3 (for example, AES256, aws:kms).

  • :storage_class (String)

    By default, Amazon S3 uses the STANDARD Storage Class to store newly created objects. The STANDARD storage class provides high durability and high availability. Depending on performance needs, you can specify a different Storage Class. Amazon S3 on Outposts only uses the OUTPOSTS Storage Class. For more information, see [Storage Classes] in the *Amazon S3 User Guide*.

    [1]: docs.aws.amazon.com/AmazonS3/latest/dev/storage-class-intro.html

  • :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 (for example, 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 S3 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 that the encryption key was transmitted without error.

  • :ssekms_key_id (String)

    Specifies the Amazon Web Services KMS key ID to use for object encryption. All GET and PUT requests for an object protected by Amazon Web Services KMS will fail if not made via SSL or using SigV4. For information about configuring using any of the officially supported Amazon Web Services SDKs and Amazon Web Services CLI, see [Specifying the Signature Version in Request Authentication] in the *Amazon S3 User Guide*.

    [1]: docs.aws.amazon.com/AmazonS3/latest/dev/UsingAWSSDK.html#specify-signature-version

  • :ssekms_encryption_context (String)

    Specifies the Amazon Web Services KMS Encryption Context to use for object encryption. The value of this header is a base64-encoded UTF-8 string holding JSON with the encryption context key-value pairs.

  • :bucket_key_enabled (Boolean)

    Specifies whether Amazon S3 should use an S3 Bucket Key for object encryption with server-side encryption using AWS KMS (SSE-KMS). Setting this header to `true` causes Amazon S3 to use an S3 Bucket Key for object encryption with SSE-KMS.

    Specifying this header with a COPY action doesn’t affect bucket-level settings for S3 Bucket Key.

  • :copy_source_sse_customer_algorithm (String)

    Specifies the algorithm to use when decrypting the source object (for example, 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 that the encryption key was transmitted without error.

  • :request_payer (String)

    Confirms that the requester knows that they will be charged for the request. Bucket owners need not specify this parameter in their requests. For information about downloading objects from requester pays buckets, see [Downloading Objects in Requestor Pays Buckets] in the *Amazon S3 User Guide*.

    [1]: 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.

  • :expected_bucket_owner (String)

    The account ID of the expected destination bucket owner. If the destination bucket is owned by a different account, the request will fail with an HTTP `403 (Access Denied)` error.

  • :expected_source_bucket_owner (String)

    The account ID of the expected source bucket owner. If the source bucket is owned by a different account, the request will fail with an HTTP `403 (Access Denied)` error.

Returns:

See Also:


1302
1303
1304
1305
# File 'lib/aws-sdk-s3/client.rb', line 1302

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

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

Creates a new S3 bucket. To create a bucket, you must register with Amazon S3 and have a valid Amazon Web Services Access Key ID to authenticate requests. Anonymous requests are never allowed to create buckets. By creating the bucket, you become the bucket owner.

Not every string is an acceptable bucket name. For information about bucket naming restrictions, see [Bucket naming rules].

If you want to create an Amazon S3 on Outposts bucket, see [Create Bucket].

By default, the bucket is created in the US East (N. Virginia) Region. You can optionally specify a Region in the request body. You might choose a Region to optimize latency, minimize costs, or address regulatory requirements. For example, if you reside in Europe, you will probably find it advantageous to create buckets in the Europe (Ireland) Region. For more information, see [Accessing a bucket].

<note markdown=“1”> If you send your create bucket request to the `s3.amazonaws.com` endpoint, the request goes to the us-east-1 Region. Accordingly, the signature calculations in Signature Version 4 must use us-east-1 as the Region, even if the location constraint in the request specifies another Region where the bucket is to be created. If you create a bucket in a Region other than US East (N. Virginia), your application must be able to handle 307 redirect. For more information, see [Virtual hosting of buckets].

</note>

When creating a bucket using this operation, you can optionally specify the accounts or groups that should be granted specific permissions on the bucket. There are two ways to grant the appropriate permissions using the request headers.

  • Specify a canned ACL using the `x-amz-acl` request header. Amazon S3 supports a set of predefined ACLs, known as *canned ACLs*. Each canned ACL has a predefined set of grantees and permissions. For more information, see [Canned ACL].

  • Specify access permissions explicitly using the `x-amz-grant-read`, `x-amz-grant-write`, `x-amz-grant-read-acp`, `x-amz-grant-write-acp`, and `x-amz-grant-full-control` headers. These headers map to the set of permissions Amazon S3 supports in an ACL. For more information, see [Access control list (ACL) overview].

    You specify each grantee as a type=value pair, where the type is one of the following:

    • `id` – if the value specified is the canonical user ID of an Amazon Web Services account

    • `uri` – if you are granting permissions to a predefined group

    • `emailAddress` – if the value specified is the email address of an Amazon Web Services account

      <note markdown=“1”> Using email addresses to specify a grantee is only supported in the following Amazon Web Services Regions:

      * US East (N. Virginia)
      
      • US West (N. California)

      • US West (Oregon)

      • Asia Pacific (Singapore)

      • Asia Pacific (Sydney)

      • Asia Pacific (Tokyo)

      • Europe (Ireland)

      • South America (São Paulo)

      For a list of all the Amazon S3 supported Regions and endpoints,
      

      see [Regions and Endpoints] in the Amazon Web Services General Reference.

      </note>
      

    For example, the following `x-amz-grant-read` header grants the Amazon Web Services accounts identified by account IDs permissions to read object data and its metadata:

    `x-amz-grant-read: id=“11112222333”, id=“444455556666” `

<note markdown=“1”> You can use either a canned ACL or specify access permissions explicitly. You cannot do both.

</note>

Permissions

If your `CreateBucket` request specifies ACL permissions and the ACL is public-read, public-read-write, authenticated-read, or if you specify access permissions explicitly through any other ACL, both `s3:CreateBucket` and `s3:PutBucketAcl` permissions are needed. If the ACL the `CreateBucket` request is private, only `s3:CreateBucket` permission is needed.

If `ObjectLockEnabledForBucket` is set to true in your `CreateBucket` request, `s3:PutBucketObjectLockConfiguration` and `s3:PutBucketVersioning` permissions are required.

The following operations are related to `CreateBucket`:

  • PutObject][8
  • DeleteBucket][9

[1]: docs.aws.amazon.com/AmazonS3/latest/userguide/bucketnamingrules.html [2]: docs.aws.amazon.com/AmazonS3/latest/API/API_control_CreateBucket.html [3]: docs.aws.amazon.com/AmazonS3/latest/dev/UsingBucket.html#access-bucket-intro [4]: docs.aws.amazon.com/AmazonS3/latest/dev/VirtualHosting.html [5]: docs.aws.amazon.com/AmazonS3/latest/dev/acl-overview.html#CannedACL [6]: docs.aws.amazon.com/AmazonS3/latest/dev/acl-overview.html [7]: docs.aws.amazon.com/general/latest/gr/rande.html#s3_region [8]: docs.aws.amazon.com/AmazonS3/latest/API/API_PutObject.html [9]: docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteBucket.html

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.<Region>.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: "af-south-1", # accepts af-south-1, ap-east-1, ap-northeast-1, ap-northeast-2, ap-northeast-3, ap-south-1, ap-southeast-1, ap-southeast-2, ca-central-1, cn-north-1, cn-northwest-1, EU, eu-central-1, eu-north-1, eu-south-1, eu-west-1, eu-west-2, eu-west-3, me-south-1, sa-east-1, us-east-2, us-gov-east-1, us-gov-west-1, us-west-1, us-west-2
  },
  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)

    The name of the bucket to create.

  • :create_bucket_configuration (Types::CreateBucketConfiguration)

    The configuration information for the bucket.

  • :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 new objects in the bucket.

    For the bucket and object owners of existing objects, also allows deletions and overwrites of those objects.

  • :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:


1521
1522
1523
1524
# File 'lib/aws-sdk-s3/client.rb', line 1521

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

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

This action initiates a multipart upload and returns an upload ID. This upload ID is used to associate all of the parts in the specific multipart upload. You specify this upload ID in each of your subsequent upload part requests (see [UploadPart]). You also include this upload ID in the final request to either complete or abort the multipart upload request.

For more information about multipart uploads, see [Multipart Upload Overview].

If you have configured a lifecycle rule to abort incomplete multipart uploads, the upload must complete within the number of days specified in the bucket lifecycle configuration. Otherwise, the incomplete multipart upload becomes eligible for an abort action and Amazon S3 aborts the multipart upload. For more information, see [Aborting Incomplete Multipart Uploads Using a Bucket Lifecycle Policy].

For information about the permissions required to use the multipart upload API, see [Multipart Upload and Permissions].

For request signing, multipart upload is just a series of regular requests. You initiate a multipart upload, send one or more requests to upload parts, and then complete the multipart upload process. You sign each request individually. There is nothing special about signing multipart upload requests. For more information about signing, see [Authenticating Requests (Amazon Web Services Signature Version 4)].

<note markdown=“1”> After you initiate a multipart upload and upload one or more parts, to stop being charged for storing the uploaded parts, you must either complete or abort the multipart upload. Amazon S3 frees up the space used to store the parts and stop charging you for storing them only after you either complete or abort a multipart upload.

</note>

You can optionally request server-side encryption. For server-side encryption, Amazon S3 encrypts your data as it writes it to disks in its data centers and decrypts it when you access it. You can provide your own encryption key, or use Amazon Web Services KMS keys or Amazon S3-managed encryption keys. If you choose to provide your own encryption key, the request headers you provide in [UploadPart] and

UploadPartCopy][6

requests must match the headers you used in the

request to initiate the upload by using `CreateMultipartUpload`.

To perform a multipart upload with encryption using an Amazon Web Services KMS key, the requester must have permission to the `kms:Decrypt` and `kms:GenerateDataKey*` actions on the key. These permissions are required because Amazon S3 must decrypt and read data from the encrypted file parts before it completes the multipart upload. For more information, see [Multipart upload API and permissions] in the *Amazon S3 User Guide*.

If your Identity and Access Management (IAM) user or role is in the same Amazon Web Services account as the KMS key, then you must have these permissions on the key policy. If your IAM user or role belongs to a different account than the key, then you must have the permissions on both the key policy and your IAM user or role.

For more information, see [Protecting Data Using Server-Side Encryption].

Access Permissions

: When copying an object, you can optionally specify the accounts or

groups that should be granted specific permissions on the new
object. There are two ways to grant the permissions using the
request headers:

* Specify a canned ACL with the `x-amz-acl` request header. For more
  information, see [Canned ACL][9].

* Specify access permissions explicitly with the `x-amz-grant-read`,
  `x-amz-grant-read-acp`, `x-amz-grant-write-acp`, and
  `x-amz-grant-full-control` headers. These parameters map to the
  set of permissions that Amazon S3 supports in an ACL. For more
  information, see [Access Control List (ACL) Overview][10].

You can use either a canned ACL or specify access permissions
explicitly. You cannot do both.

Server-Side- Encryption-Specific Request Headers

: You can optionally tell Amazon S3 to encrypt data at rest using

server-side encryption. Server-side encryption is for data
encryption at rest. Amazon S3 encrypts your data as it writes it to
disks in its data centers and decrypts it when you access it. The
option you use depends on whether you want to use Amazon Web
Services managed encryption keys or provide your own encryption key.

* Use encryption keys managed by Amazon S3 or customer managed key
  stored in Amazon Web Services Key Management Service (Amazon Web
  Services KMS) – If you want Amazon Web Services to manage the keys
  used to encrypt data, specify the following headers in the
  request.

  * x-amz-server-side-encryption

  * x-amz-server-side-encryption-aws-kms-key-id

  * x-amz-server-side-encryption-context

  <note markdown="1"> If you specify `x-amz-server-side-encryption:aws:kms`, but don't
  provide `x-amz-server-side-encryption-aws-kms-key-id`, Amazon S3
  uses the Amazon Web Services managed key in Amazon Web Services
  KMS to protect the data.

   </note>

  All GET and PUT requests for an object protected by Amazon Web
  Services KMS fail if you don't make them with SSL or by using
  SigV4.

  For more information about server-side encryption with KMS key
  (SSE-KMS), see [Protecting Data Using Server-Side Encryption with
  KMS keys][11].

* Use customer-provided encryption keys – If you want to manage your
  own encryption keys, provide all the following headers in the
  request.

  * x-amz-server-side-encryption-customer-algorithm

  * x-amz-server-side-encryption-customer-key

  * x-amz-server-side-encryption-customer-key-MD5

  For more information about server-side encryption with KMS keys
  (SSE-KMS), see [Protecting Data Using Server-Side Encryption with
  KMS keys][11].

Access-Control-List (ACL)-Specific Request Headers

: You also can use the following access control–related headers with

this operation. By default, all objects are private. Only the owner
has full access control. When adding a new object, you can grant
permissions to individual Amazon Web Services accounts or to
predefined groups defined by Amazon S3. These permissions are then
added to the access control list (ACL) on the object. For more
information, see [Using ACLs][12]. With this operation, you can
grant access permissions using one of the following two methods:

* Specify a canned ACL (`x-amz-acl`) — Amazon S3 supports a set of
  predefined ACLs, known as *canned ACLs*. Each canned ACL has a
  predefined set of grantees and permissions. For more information,
  see [Canned ACL][9].

* Specify access permissions explicitly — To explicitly grant access
  permissions to specific Amazon Web Services accounts or groups,
  use the following headers. Each header maps to specific
  permissions that Amazon S3 supports in an ACL. For more
  information, see [Access Control List (ACL) Overview][10]. In the
  header, you specify a list of grantees who get the specific
  permission. To grant permissions explicitly, use:

  * x-amz-grant-read

  * x-amz-grant-write

  * x-amz-grant-read-acp

  * x-amz-grant-write-acp

  * x-amz-grant-full-control

  You specify each grantee as a type=value pair, where the type is
  one of the following:

  * `id` – if the value specified is the canonical user ID of an
    Amazon Web Services account

  * `uri` – if you are granting permissions to a predefined group

  * `emailAddress` – if the value specified is the email address of
    an Amazon Web Services account

    <note markdown="1"> Using email addresses to specify a grantee is only supported in
    the following Amazon Web Services Regions:

     * US East (N. Virginia)

    * US West (N. California)

    * US West (Oregon)

    * Asia Pacific (Singapore)

    * Asia Pacific (Sydney)

    * Asia Pacific (Tokyo)

    * Europe (Ireland)

    * South America (São Paulo)

     For a list of all the Amazon S3 supported Regions and endpoints,
    see [Regions and Endpoints][13] in the Amazon Web Services
    General Reference.

     </note>

  For example, the following `x-amz-grant-read` header grants the
  Amazon Web Services accounts identified by account IDs permissions
  to read object data and its metadata:

  `x-amz-grant-read: id="11112222333", id="444455556666" `

The following operations are related to `CreateMultipartUpload`:

  • UploadPart][1
  • CompleteMultipartUpload][14
  • AbortMultipartUpload][15
  • ListParts][16
  • ListMultipartUploads][17

[1]: docs.aws.amazon.com/AmazonS3/latest/API/API_UploadPart.html [2]: docs.aws.amazon.com/AmazonS3/latest/dev/mpuoverview.html [3]: docs.aws.amazon.com/AmazonS3/latest/dev/mpuoverview.html#mpu-abort-incomplete-mpu-lifecycle-config [4]: docs.aws.amazon.com/AmazonS3/latest/dev/mpuAndPermissions.html [5]: docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-authenticating-requests.html [6]: docs.aws.amazon.com/AmazonS3/latest/API/API_UploadPartCopy.html [7]: docs.aws.amazon.com/AmazonS3/latest/userguide/mpuoverview.html#mpuAndPermissions [8]: docs.aws.amazon.com/AmazonS3/latest/dev/serv-side-encryption.html [9]: docs.aws.amazon.com/AmazonS3/latest/dev/acl-overview.html#CannedACL [10]: docs.aws.amazon.com/AmazonS3/latest/dev/acl-overview.html [11]: docs.aws.amazon.com/AmazonS3/latest/dev/UsingKMSEncryption.html [12]: docs.aws.amazon.com/AmazonS3/latest/dev/S3_ACLs_UsingACLs.html [13]: docs.aws.amazon.com/general/latest/gr/rande.html#s3_region [14]: docs.aws.amazon.com/AmazonS3/latest/API/API_CompleteMultipartUpload.html [15]: docs.aws.amazon.com/AmazonS3/latest/API/API_AbortMultipartUpload.html [16]: docs.aws.amazon.com/AmazonS3/latest/API/API_ListParts.html [17]: docs.aws.amazon.com/AmazonS3/latest/API/API_ListMultipartUploads.html

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, DEEP_ARCHIVE, OUTPOSTS
  website_redirect_location: "WebsiteRedirectLocation",
  sse_customer_algorithm: "SSECustomerAlgorithm",
  sse_customer_key: "SSECustomerKey",
  sse_customer_key_md5: "SSECustomerKeyMD5",
  ssekms_key_id: "SSEKMSKeyId",
  ssekms_encryption_context: "SSEKMSEncryptionContext",
  bucket_key_enabled: false,
  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
  expected_bucket_owner: "AccountId",
})

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.ssekms_encryption_context #=> String
resp.bucket_key_enabled #=> Boolean
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.

    This action is not supported by Amazon S3 on Outposts.

  • :bucket (required, String)

    The name of the bucket to which to initiate the upload

    When using this action with an access point, you must direct requests to the access point hostname. The access point hostname takes the form AccessPointName-AccountId.s3-accesspoint.Region.amazonaws.com. When using this action with an access point through the Amazon Web Services SDKs, you provide the access point ARN in place of the bucket name. For more information about access point ARNs, see [Using access points] in the *Amazon S3 User Guide*.

    When using this action with Amazon S3 on Outposts, you must direct requests to the S3 on Outposts hostname. The S3 on Outposts hostname takes the form AccessPointName-AccountId.outpostID.s3-outposts.Region.amazonaws.com. When using this action using S3 on Outposts through the Amazon Web Services SDKs, you provide the Outposts bucket ARN in place of the bucket name. For more information about S3 on Outposts ARNs, see

    Using S3 on Outposts][2

    in the *Amazon S3 User Guide*.

    [1]: docs.aws.amazon.com/AmazonS3/latest/userguide/using-access-points.html [2]: docs.aws.amazon.com/AmazonS3/latest/userguide/S3onOutposts.html

  • :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.

    This action is not supported by Amazon S3 on Outposts.

  • :grant_read (String)

    Allows grantee to read the object data and its metadata.

    This action is not supported by Amazon S3 on Outposts.

  • :grant_read_acp (String)

    Allows grantee to read the object ACL.

    This action is not supported by Amazon S3 on Outposts.

  • :grant_write_acp (String)

    Allows grantee to write the ACL for the applicable object.

    This action is not supported by Amazon S3 on Outposts.

  • :key (required, String)

    Object key for which the multipart upload is to be 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 Amazon S3 (for example, AES256, aws:kms).

  • :storage_class (String)

    By default, Amazon S3 uses the STANDARD Storage Class to store newly created objects. The STANDARD storage class provides high durability and high availability. Depending on performance needs, you can specify a different Storage Class. Amazon S3 on Outposts only uses the OUTPOSTS Storage Class. For more information, see [Storage Classes] in the *Amazon S3 User Guide*.

    [1]: docs.aws.amazon.com/AmazonS3/latest/dev/storage-class-intro.html

  • :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 (for example, 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 S3 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 that the encryption key was transmitted without error.

  • :ssekms_key_id (String)

    Specifies the ID of the symmetric customer managed key to use for object encryption. All GET and PUT requests for an object protected by Amazon Web Services KMS will fail if not made via SSL or using SigV4. For information about configuring using any of the officially supported Amazon Web Services SDKs and Amazon Web Services CLI, see

    Specifying the Signature Version in Request Authentication][1

    in the

    *Amazon S3 User Guide*.

    [1]: docs.aws.amazon.com/AmazonS3/latest/dev/UsingAWSSDK.html#specify-signature-version

  • :ssekms_encryption_context (String)

    Specifies the Amazon Web Services KMS Encryption Context to use for object encryption. The value of this header is a base64-encoded UTF-8 string holding JSON with the encryption context key-value pairs.

  • :bucket_key_enabled (Boolean)

    Specifies whether Amazon S3 should use an S3 Bucket Key for object encryption with server-side encryption using AWS KMS (SSE-KMS). Setting this header to `true` causes Amazon S3 to use an S3 Bucket Key for object encryption with SSE-KMS.

    Specifying this header with an object action doesn’t affect bucket-level settings for S3 Bucket Key.

  • :request_payer (String)

    Confirms that the requester knows that they will be charged for the request. Bucket owners need not specify this parameter in their requests. For information about downloading objects from requester pays buckets, see [Downloading Objects in Requestor Pays Buckets] in the *Amazon S3 User Guide*.

    [1]: 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.

  • :expected_bucket_owner (String)

    The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP `403 (Access Denied)` error.

Returns:

See Also:


2024
2025
2026
2027
# File 'lib/aws-sdk-s3/client.rb', line 2024

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

#delete_bucket(params = {}) ⇒ Struct

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

**Related Resources**

  • CreateBucket][1
  • DeleteObject][2

[1]: docs.aws.amazon.com/AmazonS3/latest/API/API_CreateBucket.html [2]: docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteObject.html

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
  expected_bucket_owner: "AccountId",
})

Parameters:

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

    ({})

Options Hash (params):

  • :bucket (required, String)

    Specifies the bucket being deleted.

  • :expected_bucket_owner (String)

    The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP `403 (Access Denied)` error.

Returns:

  • (Struct)

    Returns an empty response.

See Also:


2074
2075
2076
2077
# File 'lib/aws-sdk-s3/client.rb', line 2074

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).

To use this operation, you must have permissions to perform the `s3:PutAnalyticsConfiguration` action. The bucket owner has this permission by default. The bucket owner can grant this permission to others. For more information about permissions, see [Permissions Related to Bucket Subresource Operations] and [Managing Access Permissions to Your Amazon S3 Resources].

For information about the Amazon S3 analytics feature, see [Amazon S3 Analytics – Storage Class Analysis].

The following operations are related to `DeleteBucketAnalyticsConfiguration`:

  • GetBucketAnalyticsConfiguration][4
  • ListBucketAnalyticsConfigurations][5
  • PutBucketAnalyticsConfiguration][6

[1]: docs.aws.amazon.com/AmazonS3/latest/userguide/using-with-s3-actions.html#using-with-s3-actions-related-to-bucket-subresources [2]: docs.aws.amazon.com/AmazonS3/latest/userguide/s3-access-control.html [3]: docs.aws.amazon.com/AmazonS3/latest/dev/analytics-storage-class.html [4]: docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketAnalyticsConfiguration.html [5]: docs.aws.amazon.com/AmazonS3/latest/API/API_ListBucketAnalyticsConfigurations.html [6]: docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketAnalyticsConfiguration.html

Examples:

Request syntax with placeholder values


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

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 ID that identifies the analytics configuration.

  • :expected_bucket_owner (String)

    The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP `403 (Access Denied)` error.

Returns:

  • (Struct)

    Returns an empty response.

See Also:


2136
2137
2138
2139
# File 'lib/aws-sdk-s3/client.rb', line 2136

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.

To use this operation, you must have permission to perform the `s3:PutBucketCORS` action. The bucket owner has this permission by default and can grant this permission to others.

For information about `cors`, see [Enabling Cross-Origin Resource Sharing] in the *Amazon S3 User Guide*.

**Related Resources:**

  • PutBucketCors][2
  • RESTOPTIONSobject][3

[1]: docs.aws.amazon.com/AmazonS3/latest/dev/cors.html [2]: docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketCors.html [3]: docs.aws.amazon.com/AmazonS3/latest/API/RESTOPTIONSobject.html

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
  expected_bucket_owner: "AccountId",
})

Parameters:

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

    ({})

Options Hash (params):

  • :bucket (required, String)

    Specifies the bucket whose `cors` configuration is being deleted.

  • :expected_bucket_owner (String)

    The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP `403 (Access Denied)` error.

Returns:

  • (Struct)

    Returns an empty response.

See Also:


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

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

#delete_bucket_encryption(params = {}) ⇒ Struct

This implementation of the DELETE action removes default encryption from the bucket. For information about the Amazon S3 default encryption feature, see [Amazon S3 Default Bucket Encryption] in the *Amazon S3 User Guide*.

To use this operation, you must have permissions to perform the `s3:PutEncryptionConfiguration` action. The bucket owner has this permission by default. The bucket owner can grant this permission to others. For more information about permissions, see [Permissions Related to Bucket Subresource Operations] and [Managing Access Permissions to your Amazon S3 Resources] in the *Amazon S3 User Guide*.

**Related Resources**

  • PutBucketEncryption][4
  • GetBucketEncryption][5

[1]: docs.aws.amazon.com/AmazonS3/latest/dev/bucket-encryption.html [2]: docs.aws.amazon.com/AmazonS3/latest/userguide/using-with-s3-actions.html#using-with-s3-actions-related-to-bucket-subresources [3]: docs.aws.amazon.com/AmazonS3/latest/userguide/s3-access-control.html [4]: docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketEncryption.html [5]: docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketEncryption.html

Examples:

Request syntax with placeholder values


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

Parameters:

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

    ({})

Options Hash (params):

  • :bucket (required, String)

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

  • :expected_bucket_owner (String)

    The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP `403 (Access Denied)` error.

Returns:

  • (Struct)

    Returns an empty response.

See Also:


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

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

#delete_bucket_intelligent_tiering_configuration(params = {}) ⇒ Struct

Deletes the S3 Intelligent-Tiering configuration from the specified bucket.

The S3 Intelligent-Tiering storage class is designed to optimize storage costs by automatically moving data to the most cost-effective storage access tier, without performance impact or operational overhead. S3 Intelligent-Tiering delivers automatic cost savings in two low latency and high throughput access tiers. For data that can be accessed asynchronously, you can choose to activate automatic archiving capabilities within the S3 Intelligent-Tiering storage class.

The S3 Intelligent-Tiering storage class is the ideal storage class for data with unknown, changing, or unpredictable access patterns, independent of object size or retention period. If the size of an object is less than 128 KB, it is not eligible for auto-tiering. Smaller objects can be stored, but they are always charged at the Frequent Access tier rates in the S3 Intelligent-Tiering storage class.

For more information, see [Storage class for automatically optimizing frequently and infrequently accessed objects].

Operations related to `DeleteBucketIntelligentTieringConfiguration` include:

  • GetBucketIntelligentTieringConfiguration][2
  • PutBucketIntelligentTieringConfiguration][3
  • ListBucketIntelligentTieringConfigurations][4

[1]: docs.aws.amazon.com/AmazonS3/latest/dev/storage-class-intro.html#sc-dynamic-data-access [2]: docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketIntelligentTieringConfiguration.html [3]: docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketIntelligentTieringConfiguration.html [4]: docs.aws.amazon.com/AmazonS3/latest/API/API_ListBucketIntelligentTieringConfigurations.html

Examples:

Request syntax with placeholder values


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

Parameters:

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

    ({})

Options Hash (params):

  • :bucket (required, String)

    The name of the Amazon S3 bucket whose configuration you want to modify or retrieve.

  • :id (required, String)

    The ID used to identify the S3 Intelligent-Tiering configuration.

Returns:

  • (Struct)

    Returns an empty response.

See Also:


2310
2311
2312
2313
# File 'lib/aws-sdk-s3/client.rb', line 2310

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

#delete_bucket_inventory_configuration(params = {}) ⇒ Struct

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

To use this operation, you must have permissions to perform the `s3:PutInventoryConfiguration` action. The bucket owner has this permission by default. The bucket owner can grant this permission to others. For more information about permissions, see [Permissions Related to Bucket Subresource Operations] and [Managing Access Permissions to Your Amazon S3 Resources].

For information about the Amazon S3 inventory feature, see [Amazon S3 Inventory].

Operations related to `DeleteBucketInventoryConfiguration` include:

  • GetBucketInventoryConfiguration][4
  • PutBucketInventoryConfiguration][5
  • ListBucketInventoryConfigurations][6

[1]: docs.aws.amazon.com/AmazonS3/latest/userguide/using-with-s3-actions.html#using-with-s3-actions-related-to-bucket-subresources [2]: docs.aws.amazon.com/AmazonS3/latest/userguide/s3-access-control.html [3]: docs.aws.amazon.com/AmazonS3/latest/dev/storage-inventory.html [4]: docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketInventoryConfiguration.html [5]: docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketInventoryConfiguration.html [6]: docs.aws.amazon.com/AmazonS3/latest/API/API_ListBucketInventoryConfigurations.html

Examples:

Request syntax with placeholder values


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

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.

  • :expected_bucket_owner (String)

    The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP `403 (Access Denied)` error.

Returns:

  • (Struct)

    Returns an empty response.

See Also:


2371
2372
2373
2374
# File 'lib/aws-sdk-s3/client.rb', line 2371

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 specified bucket. Amazon S3 removes all the lifecycle configuration rules in the lifecycle subresource associated with the bucket. Your objects never expire, and Amazon S3 no longer automatically deletes any objects on the basis of rules contained in the deleted lifecycle configuration.

To use this operation, you must have permission to perform the `s3:PutLifecycleConfiguration` action. By default, the bucket owner has this permission and the bucket owner can grant this permission to others.

There is usually some time lag before lifecycle configuration deletion is fully propagated to all the Amazon S3 systems.

For more information about the object expiration, see [Elements to Describe Lifecycle Actions].

Related actions include:

  • PutBucketLifecycleConfiguration][2
  • GetBucketLifecycleConfiguration][3

[1]: docs.aws.amazon.com/AmazonS3/latest/dev/intro-lifecycle-rules.html#intro-lifecycle-rules-actions [2]: docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketLifecycleConfiguration.html [3]: docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketLifecycleConfiguration.html

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
  expected_bucket_owner: "AccountId",
})

Parameters:

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

    ({})

Options Hash (params):

  • :bucket (required, String)

    The bucket name of the lifecycle to delete.

  • :expected_bucket_owner (String)

    The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP `403 (Access Denied)` error.

Returns:

  • (Struct)

    Returns an empty response.

See Also:


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

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 for the Amazon CloudWatch request metrics (specified by the metrics configuration ID) from the bucket. Note that this doesn't include the daily storage metrics.

To use this operation, you must have permissions to perform the `s3:PutMetricsConfiguration` action. The bucket owner has this permission by default. The bucket owner can grant this permission to others. For more information about permissions, see [Permissions Related to Bucket Subresource Operations] and [Managing Access Permissions to Your Amazon S3 Resources].

For information about CloudWatch request metrics for Amazon S3, see [Monitoring Metrics with Amazon CloudWatch].

The following operations are related to `DeleteBucketMetricsConfiguration`:

  • GetBucketMetricsConfiguration][4
  • PutBucketMetricsConfiguration][5
  • ListBucketMetricsConfigurations][6
  • Monitoring Metrics with Amazon CloudWatch][3

[1]: docs.aws.amazon.com/AmazonS3/latest/userguide/using-with-s3-actions.html#using-with-s3-actions-related-to-bucket-subresources [2]: docs.aws.amazon.com/AmazonS3/latest/userguide/s3-access-control.html [3]: docs.aws.amazon.com/AmazonS3/latest/dev/cloudwatch-monitoring.html [4]: docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketMetricsConfiguration.html [5]: docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketMetricsConfiguration.html [6]: docs.aws.amazon.com/AmazonS3/latest/API/API_ListBucketMetricsConfigurations.html

Examples:

Request syntax with placeholder values


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

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.

  • :expected_bucket_owner (String)

    The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP `403 (Access Denied)` error.

Returns:

  • (Struct)

    Returns an empty response.

See Also:


2499
2500
2501
2502
# File 'lib/aws-sdk-s3/client.rb', line 2499

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

#delete_bucket_ownership_controls(params = {}) ⇒ Struct

Removes `OwnershipControls` for an Amazon S3 bucket. To use this operation, you must have the `s3:PutBucketOwnershipControls` permission. For more information about Amazon S3 permissions, see [Specifying Permissions in a Policy].

For information about Amazon S3 Object Ownership, see [Using Object Ownership].

The following operations are related to `DeleteBucketOwnershipControls`:

  • GetBucketOwnershipControls

  • PutBucketOwnershipControls

[1]: docs.aws.amazon.com/AmazonS3/latest/dev/using-with-s3-actions.html [2]: docs.aws.amazon.com/AmazonS3/latest/dev/about-object-ownership.html

Examples:

Request syntax with placeholder values


resp = client.delete_bucket_ownership_controls({
  bucket: "BucketName", # required
  expected_bucket_owner: "AccountId",
})

Parameters:

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

    ({})

Options Hash (params):

  • :bucket (required, String)

    The Amazon S3 bucket whose `OwnershipControls` you want to delete.

  • :expected_bucket_owner (String)

    The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP `403 (Access Denied)` error.

Returns:

  • (Struct)

    Returns an empty response.

See Also:


2545
2546
2547
2548
# File 'lib/aws-sdk-s3/client.rb', line 2545

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

#delete_bucket_policy(params = {}) ⇒ Struct

This implementation of the DELETE action uses the policy subresource to delete the policy of a specified bucket. If you are using an identity other than the root user of the Amazon Web Services account that owns the bucket, the calling identity must have the `DeleteBucketPolicy` permissions on the specified bucket and belong to the bucket owner's account to use this operation.

If you don't have `DeleteBucketPolicy` permissions, Amazon S3 returns a `403 Access Denied` error. If you have the correct permissions, but you're not using an identity that belongs to the bucket owner's account, Amazon S3 returns a `405 Method Not Allowed` error.

As a security precaution, the root user of the Amazon Web Services account that owns a bucket can always use this operation, even if the policy explicitly denies the root user the ability to perform this action.

For more information about bucket policies, see [Using Bucket Policies and UserPolicies].

The following operations are related to `DeleteBucketPolicy`

  • CreateBucket][2
  • DeleteObject][3

[1]: docs.aws.amazon.com/AmazonS3/latest/dev/using-iam-policies.html [2]: docs.aws.amazon.com/AmazonS3/latest/API/API_CreateBucket.html [3]: docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteObject.html

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
  expected_bucket_owner: "AccountId",
})

Parameters:

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

    ({})

Options Hash (params):

  • :bucket (required, String)

    The bucket name.

  • :expected_bucket_owner (String)

    The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP `403 (Access Denied)` error.

Returns:

  • (Struct)

    Returns an empty response.

See Also:


2612
2613
2614
2615
# File 'lib/aws-sdk-s3/client.rb', line 2612

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.

To use this operation, you must have permissions to perform the `s3:PutReplicationConfiguration` action. The bucket owner has these permissions by default and can grant it to others. For more information about permissions, see [Permissions Related to Bucket Subresource Operations] and [Managing Access Permissions to Your Amazon S3 Resources].

<note markdown=“1”> It can take a while for the deletion of a replication configuration to fully propagate.

</note>

For information about replication configuration, see [Replication] in the *Amazon S3 User Guide*.

The following operations are related to `DeleteBucketReplication`:

  • PutBucketReplication][4
  • GetBucketReplication][5

[1]: docs.aws.amazon.com/AmazonS3/latest/userguide/using-with-s3-actions.html#using-with-s3-actions-related-to-bucket-subresources [2]: docs.aws.amazon.com/AmazonS3/latest/userguide/s3-access-control.html [3]: docs.aws.amazon.com/AmazonS3/latest/dev/replication.html [4]: docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketReplication.html [5]: docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketReplication.html

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
  expected_bucket_owner: "AccountId",
})

Parameters:

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

    ({})

Options Hash (params):

  • :bucket (required, String)

    The bucket name.

  • :expected_bucket_owner (String)

    The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP `403 (Access Denied)` error.

Returns:

  • (Struct)

    Returns an empty response.

See Also:


2678
2679
2680
2681
# File 'lib/aws-sdk-s3/client.rb', line 2678

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.

To use this operation, you must have permission to perform the `s3:PutBucketTagging` action. By default, the bucket owner has this permission and can grant this permission to others.

The following operations are related to `DeleteBucketTagging`:

  • GetBucketTagging][1
  • PutBucketTagging][2

[1]: docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketTagging.html [2]: docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketTagging.html

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
  expected_bucket_owner: "AccountId",
})

Parameters:

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

    ({})

Options Hash (params):

  • :bucket (required, String)

    The bucket that has the tag set to be removed.

  • :expected_bucket_owner (String)

    The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP `403 (Access Denied)` error.

Returns:

  • (Struct)

    Returns an empty response.

See Also:


2730
2731
2732
2733
# File 'lib/aws-sdk-s3/client.rb', line 2730

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

#delete_bucket_website(params = {}) ⇒ Struct

This action removes the website configuration for a bucket. Amazon S3 returns a `200 OK` response upon successfully deleting a website configuration on the specified bucket. You will get a `200 OK` response if the website configuration you are trying to delete does not exist on the bucket. Amazon S3 returns a `404` response if the bucket specified in the request does not exist.

This DELETE action requires the `S3:DeleteBucketWebsite` permission. By default, only the bucket owner can delete the website configuration attached to a bucket. However, bucket owners can grant other users permission to delete the website configuration by writing a bucket policy granting them the `S3:DeleteBucketWebsite` permission.

For more information about hosting websites, see [Hosting Websites on Amazon S3].

The following operations are related to `DeleteBucketWebsite`:

  • GetBucketWebsite][2
  • PutBucketWebsite][3

[1]: docs.aws.amazon.com/AmazonS3/latest/dev/WebsiteHosting.html [2]: docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketWebsite.html [3]: docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketWebsite.html

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
  expected_bucket_owner: "AccountId",
})

Parameters:

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

    ({})

Options Hash (params):

  • :bucket (required, String)

    The bucket name for which you want to remove the website configuration.

  • :expected_bucket_owner (String)

    The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP `403 (Access Denied)` error.

Returns:

  • (Struct)

    Returns an empty response.

See Also:


2794
2795
2796
2797
# File 'lib/aws-sdk-s3/client.rb', line 2794

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 but will still respond that the command was successful.

To remove a specific version, you must be the bucket owner and you must use the version Id subresource. Using this subresource permanently deletes the version. If the object deleted is a delete marker, Amazon S3 sets the response header, `x-amz-delete-marker`, to true.

If the object you want to delete is in a bucket where the bucket versioning configuration is MFA Delete enabled, you must include the `x-amz-mfa` request header in the DELETE `versionId` request. Requests that include `x-amz-mfa` must use HTTPS.

For more information about MFA Delete, see [Using MFA Delete]. To see sample requests that use versioning, see [Sample Request].

You can delete objects by explicitly calling DELETE Object or configure its lifecycle ([PutBucketLifecycle]) to enable Amazon S3 to remove them for you. If you want to block users or accounts from removing or deleting objects from your bucket, you must deny them the `s3:DeleteObject`, `s3:DeleteObjectVersion`, and `s3:PutLifeCycleConfiguration` actions.

The following action is related to `DeleteObject`:

  • PutObject][4

^

[1]: docs.aws.amazon.com/AmazonS3/latest/dev/UsingMFADelete.html [2]: docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectDELETE.html#ExampleVersionObjectDelete [3]: docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketLifecycle.html [4]: docs.aws.amazon.com/AmazonS3/latest/API/API_PutObject.html

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,
  expected_bucket_owner: "AccountId",
})

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)

    The bucket name of the bucket containing the object.

    When using this action with an access point, you must direct requests to the access point hostname. The access point hostname takes the form AccessPointName-AccountId.s3-accesspoint.Region.amazonaws.com. When using this action with an access point through the Amazon Web Services SDKs, you provide the access point ARN in place of the bucket name. For more information about access point ARNs, see [Using access points] in the *Amazon S3 User Guide*.

    When using this action with Amazon S3 on Outposts, you must direct requests to the S3 on Outposts hostname. The S3 on Outposts hostname takes the form AccessPointName-AccountId.outpostID.s3-outposts.Region.amazonaws.com. When using this action using S3 on Outposts through the Amazon Web Services SDKs, you provide the Outposts bucket ARN in place of the bucket name. For more information about S3 on Outposts ARNs, see

    Using S3 on Outposts][2

    in the *Amazon S3 User Guide*.

    [1]: docs.aws.amazon.com/AmazonS3/latest/userguide/using-access-points.html [2]: docs.aws.amazon.com/AmazonS3/latest/userguide/S3onOutposts.html

  • :key (required, String)

    Key name of the object to delete.

  • :mfa (String)

    The concatenation of the authentication device's serial number, a space, and the value that is displayed on your authentication device. Required to permanently delete a versioned object if versioning is configured with MFA delete enabled.

  • :version_id (String)

    VersionId used to reference a specific version of the object.

  • :request_payer (String)

    Confirms that the requester knows that they will be charged for the request. Bucket owners need not specify this parameter in their requests. For information about downloading objects from requester pays buckets, see [Downloading Objects in Requestor Pays Buckets] in the *Amazon S3 User Guide*.

    [1]: 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. To use this header, you must have the `s3:PutBucketPublicAccessBlock` permission.

  • :expected_bucket_owner (String)

    The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP `403 (Access Denied)` error.

Returns:

See Also:


2947
2948
2949
2950
# File 'lib/aws-sdk-s3/client.rb', line 2947

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

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

Removes the entire tag set from the specified object. For more information about managing object tags, see [ Object Tagging].

To use this operation, you must have permission to perform the `s3:DeleteObjectTagging` action.

To delete tags of a specific object version, add the `versionId` query parameter in the request. You will need permission for the `s3:DeleteObjectVersionTagging` action.

The following operations are related to `DeleteBucketMetricsConfiguration`:

  • PutObjectTagging][2
  • GetObjectTagging][3

[1]: docs.aws.amazon.com/AmazonS3/latest/dev/object-tagging.html [2]: docs.aws.amazon.com/AmazonS3/latest/API/API_PutObjectTagging.html [3]: docs.aws.amazon.com/AmazonS3/latest/API/API_GetObjectTagging.html

Examples:

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", 
}

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", 
}

Request syntax with placeholder values


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

Response structure


resp.version_id #=> String

Parameters:

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

    ({})

Options Hash (params):

  • :bucket (required, String)

    The bucket name containing the objects from which to remove the tags.

    When using this action with an access point, you must direct requests to the access point hostname. The access point hostname takes the form AccessPointName-AccountId.s3-accesspoint.Region.amazonaws.com. When using this action with an access point through the Amazon Web Services SDKs, you provide the access point ARN in place of the bucket name. For more information about access point ARNs, see [Using access points] in the *Amazon S3 User Guide*.

    When using this action with Amazon S3 on Outposts, you must direct requests to the S3 on Outposts hostname. The S3 on Outposts hostname takes the form AccessPointName-AccountId.outpostID.s3-outposts.Region.amazonaws.com. When using this action using S3 on Outposts through the Amazon Web Services SDKs, you provide the Outposts bucket ARN in place of the bucket name. For more information about S3 on Outposts ARNs, see

    Using S3 on Outposts][2

    in the *Amazon S3 User Guide*.

    [1]: docs.aws.amazon.com/AmazonS3/latest/userguide/using-access-points.html [2]: docs.aws.amazon.com/AmazonS3/latest/userguide/S3onOutposts.html

  • :key (required, String)

    The key that identifies the object in the bucket from which to remove all tags.

  • :version_id (String)

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

  • :expected_bucket_owner (String)

    The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP `403 (Access Denied)` error.

Returns:

See Also:


3065
3066
3067
3068
# File 'lib/aws-sdk-s3/client.rb', line 3065

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

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

This action enables you to delete multiple objects from a bucket using a single HTTP request. If you know the object keys that you want to delete, then this action provides a suitable alternative to sending individual delete requests, reducing per-request overhead.

The request contains a list of up to 1000 keys that you want to delete. In the XML, you provide the object key names, and optionally, version IDs if you want to delete a specific version of the object from a versioning-enabled bucket. For each key, Amazon S3 performs a delete action and returns the result of that delete, success, or failure, in the response. Note that if the object specified in the request is not found, Amazon S3 returns the result as deleted.

The action supports two modes for the response: verbose and quiet. By default, the action uses verbose mode in which the response includes the result of deletion of each key in your request. In quiet mode the response includes only keys where the delete action encountered an error. For a successful deletion, the action does not return any information about the delete in the response body.

When performing this action on an MFA Delete enabled bucket, that attempts to delete any versioned objects, you must include an MFA token. If you do not provide one, the entire request will fail, even if there are non-versioned objects you are trying to delete. If you provide an invalid token, whether there are versioned keys in the request or not, the entire Multi-Object Delete request will fail. For information about MFA Delete, see [ MFA Delete].

Finally, the Content-MD5 header is required for all Multi-Object Delete requests. Amazon S3 uses the header value to ensure that your request body has not been altered in transit.

The following operations are related to `DeleteObjects`:

  • CreateMultipartUpload][2
  • UploadPart][3
  • CompleteMultipartUpload][4
  • ListParts][5
  • AbortMultipartUpload][6

[1]: docs.aws.amazon.com/AmazonS3/latest/dev/Versioning.html#MultiFactorAuthenticationDelete [2]: docs.aws.amazon.com/AmazonS3/latest/API/API_CreateMultipartUpload.html [3]: docs.aws.amazon.com/AmazonS3/latest/API/API_UploadPart.html [4]: docs.aws.amazon.com/AmazonS3/latest/API/API_CompleteMultipartUpload.html [5]: docs.aws.amazon.com/AmazonS3/latest/API/API_ListParts.html [6]: docs.aws.amazon.com/AmazonS3/latest/API/API_AbortMultipartUpload.html

Examples:

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", 
    }, 
  ], 
}

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", 
    }, 
  ], 
}

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,
  expected_bucket_owner: "AccountId",
})

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)

    The bucket name containing the objects to delete.

    When using this action with an access point, you must direct requests to the access point hostname. The access point hostname takes the form AccessPointName-AccountId.s3-accesspoint.Region.amazonaws.com. When using this action with an access point through the Amazon Web Services SDKs, you provide the access point ARN in place of the bucket name. For more information about access point ARNs, see [Using access points] in the *Amazon S3 User Guide*.

    When using this action with Amazon S3 on Outposts, you must direct requests to the S3 on Outposts hostname. The S3 on Outposts hostname takes the form AccessPointName-AccountId.outpostID.s3-outposts.Region.amazonaws.com. When using this action using S3 on Outposts through the Amazon Web Services SDKs, you provide the Outposts bucket ARN in place of the bucket name. For more information about S3 on Outposts ARNs, see

    Using S3 on Outposts][2

    in the *Amazon S3 User Guide*.

    [1]: docs.aws.amazon.com/AmazonS3/latest/userguide/using-access-points.html [2]: docs.aws.amazon.com/AmazonS3/latest/userguide/S3onOutposts.html

  • :delete (required, Types::Delete)

    Container for the request.

  • :mfa (String)

    The concatenation of the authentication device's serial number, a space, and the value that is displayed on your authentication device. Required to permanently delete a versioned object if versioning is configured with MFA delete enabled.

  • :request_payer (String)

    Confirms that the requester knows that they will be charged for the request. Bucket owners need not specify this parameter in their requests. For information about downloading objects from requester pays buckets, see [Downloading Objects in Requestor Pays Buckets] in the *Amazon S3 User Guide*.

    [1]: 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. To use this header, you must have the `s3:PutBucketPublicAccessBlock` permission.

  • :expected_bucket_owner (String)

    The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP `403 (Access Denied)` error.

Returns:

See Also:


3294
3295
3296
3297
# File 'lib/aws-sdk-s3/client.rb', line 3294

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 for an Amazon S3 bucket. To use this operation, you must have the `s3:PutBucketPublicAccessBlock` permission. For more information about permissions, see [Permissions Related to Bucket Subresource Operations] and [Managing Access Permissions to Your Amazon S3 Resources].

The following operations are related to `DeletePublicAccessBlock`:

  • Using Amazon S3 Block Public Access][3
  • GetPublicAccessBlock][4
  • PutPublicAccessBlock][5
  • GetBucketPolicyStatus][6

[1]: docs.aws.amazon.com/AmazonS3/latest/userguide/using-with-s3-actions.html#using-with-s3-actions-related-to-bucket-subresources [2]: docs.aws.amazon.com/AmazonS3/latest/userguide/s3-access-control.html [3]: docs.aws.amazon.com/AmazonS3/latest/dev/access-control-block-public-access.html [4]: docs.aws.amazon.com/AmazonS3/latest/API/API_GetPublicAccessBlock.html [5]: docs.aws.amazon.com/AmazonS3/latest/API/API_PutPublicAccessBlock.html [6]: docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketPolicyStatus.html

Examples:

Request syntax with placeholder values


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

Parameters:

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

    ({})

Options Hash (params):

  • :bucket (required, String)

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

  • :expected_bucket_owner (String)

    The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP `403 (Access Denied)` error.

Returns:

  • (Struct)

    Returns an empty response.

See Also:


3347
3348
3349
3350
# File 'lib/aws-sdk-s3/client.rb', line 3347

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

This implementation of the GET action uses the `accelerate` subresource to return the Transfer Acceleration state of a bucket, which is either `Enabled` or `Suspended`. Amazon S3 Transfer Acceleration is a bucket-level feature that enables you to perform faster data transfers to and from Amazon S3.

To use this operation, you must have permission to perform the `s3:GetAccelerateConfiguration` action. The bucket owner has this permission by default. The bucket owner can grant this permission to others. For more information about permissions, see [Permissions Related to Bucket Subresource Operations] and [Managing Access Permissions to your Amazon S3 Resources] in the *Amazon S3 User Guide*.

You set the Transfer Acceleration state of an existing bucket to `Enabled` or `Suspended` by using the

PutBucketAccelerateConfiguration][3

operation.

A GET `accelerate` request does not return a state value for a bucket that has no transfer acceleration state. A bucket has no Transfer Acceleration state if a state has never been set on the bucket.

For more information about transfer acceleration, see [Transfer Acceleration] in the Amazon S3 User Guide.

**Related Resources**

  • PutBucketAccelerateConfiguration][3

^

[1]: docs.aws.amazon.com/AmazonS3/latest/userguide/using-with-s3-actions.html#using-with-s3-actions-related-to-bucket-subresources [2]: docs.aws.amazon.com/AmazonS3/latest/userguide/s3-access-control.html [3]: docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketAccelerateConfiguration.html [4]: docs.aws.amazon.com/AmazonS3/latest/dev/transfer-acceleration.html

Examples:

Request syntax with placeholder values


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

Response structure


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

Parameters:

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

    ({})

Options Hash (params):

  • :bucket (required, String)

    The name of the bucket for which the accelerate configuration is retrieved.

  • :expected_bucket_owner (String)

    The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP `403 (Access Denied)` error.

Returns:

See Also:


3418
3419
3420
3421
# File 'lib/aws-sdk-s3/client.rb', line 3418

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

This implementation of the `GET` action uses the `acl` subresource to return the access control list (ACL) of a bucket. To use `GET` to return the ACL of the bucket, you must have `READ_ACP` access to the bucket. If `READ_ACP` permission is granted to the anonymous user, you can return the ACL of the bucket without using an authorization header.

**Related Resources**

  • ListObjects][1

^

[1]: docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjects.html

Examples:

Request syntax with placeholder values


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

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)

    Specifies the S3 bucket whose ACL is being requested.

  • :expected_bucket_owner (String)

    The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP `403 (Access Denied)` error.

Returns:

See Also:


3476
3477
3478
3479
# File 'lib/aws-sdk-s3/client.rb', line 3476

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

This implementation of the GET action returns an analytics configuration (identified by the analytics configuration ID) from the bucket.

To use this operation, you must have permissions to perform the `s3:GetAnalyticsConfiguration` action. The bucket owner has this permission by default. The bucket owner can grant this permission to others. For more information about permissions, see [ Permissions Related to Bucket Subresource Operations] and [Managing Access Permissions to Your Amazon S3 Resources] in the *Amazon S3 User Guide*.

For information about Amazon S3 analytics feature, see [Amazon S3 Analytics – Storage Class Analysis] in the *Amazon S3 User Guide*.

**Related Resources**

  • DeleteBucketAnalyticsConfiguration][4
  • ListBucketAnalyticsConfigurations][5
  • PutBucketAnalyticsConfiguration][6

[1]: docs.aws.amazon.com/AmazonS3/latest/userguide/using-with-s3-actions.html#using-with-s3-actions-related-to-bucket-subresources [2]: docs.aws.amazon.com/AmazonS3/latest/userguide/s3-access-control.html [3]: docs.aws.amazon.com/AmazonS3/latest/dev/analytics-storage-class.html [4]: docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteBucketAnalyticsConfiguration.html [5]: docs.aws.amazon.com/AmazonS3/latest/API/API_ListBucketAnalyticsConfigurations.html [6]: docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketAnalyticsConfiguration.html

Examples:

Request syntax with placeholder values


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

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 ID that identifies the analytics configuration.

  • :expected_bucket_owner (String)

    The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP `403 (Access Denied)` error.

Returns:

See Also:


3557
3558
3559
3560
# File 'lib/aws-sdk-s3/client.rb', line 3557

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 information set for the bucket.

To use this operation, you must have permission to perform the s3:GetBucketCORS action. By default, the bucket owner has this permission and can grant it to others.

For more information about cors, see [ Enabling Cross-Origin Resource Sharing].

The following operations are related to `GetBucketCors`:

  • PutBucketCors][2
  • DeleteBucketCors][3

[1]: docs.aws.amazon.com/AmazonS3/latest/dev/cors.html [2]: docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketCors.html [3]: docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteBucketCors.html

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
  expected_bucket_owner: "AccountId",
})

Response structure


resp.cors_rules #=> Array
resp.cors_rules[0].id #=> String
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)

    The bucket name for which to get the cors configuration.

  • :expected_bucket_owner (String)

    The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP `403 (Access Denied)` error.

Returns:

See Also:


3647
3648
3649
3650
# File 'lib/aws-sdk-s3/client.rb', line 3647

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 default encryption configuration for an Amazon S3 bucket. If the bucket does not have a default encryption configuration, GetBucketEncryption returns `ServerSideEncryptionConfigurationNotFoundError`.

For information about the Amazon S3 default encryption feature, see [Amazon S3 Default Bucket Encryption].

To use this operation, you must have permission to perform the `s3:GetEncryptionConfiguration` action. The bucket owner has this permission by default. The bucket owner can grant this permission to others. For more information about permissions, see [Permissions Related to Bucket Subresource Operations] and [Managing Access Permissions to Your Amazon S3 Resources].

The following operations are related to `GetBucketEncryption`:

  • PutBucketEncryption][4
  • DeleteBucketEncryption][5

[1]: docs.aws.amazon.com/AmazonS3/latest/dev/bucket-encryption.html [2]: docs.aws.amazon.com/AmazonS3/latest/userguide/using-with-s3-actions.html#using-with-s3-actions-related-to-bucket-subresources [3]: docs.aws.amazon.com/AmazonS3/latest/userguide/s3-access-control.html [4]: docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketEncryption.html [5]: docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteBucketEncryption.html

Examples:

Request syntax with placeholder values


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

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
resp.server_side_encryption_configuration.rules[0].bucket_key_enabled #=> Boolean

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.

  • :expected_bucket_owner (String)

    The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP `403 (Access Denied)` error.

Returns:

See Also:


3712
3713
3714
3715
# File 'lib/aws-sdk-s3/client.rb', line 3712

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

#get_bucket_intelligent_tiering_configuration(params = {}) ⇒ Types::GetBucketIntelligentTieringConfigurationOutput

Gets the S3 Intelligent-Tiering configuration from the specified bucket.

The S3 Intelligent-Tiering storage class is designed to optimize storage costs by automatically moving data to the most cost-effective storage access tier, without performance impact or operational overhead. S3 Intelligent-Tiering delivers automatic cost savings in two low latency and high throughput access tiers. For data that can be accessed asynchronously, you can choose to activate automatic archiving capabilities within the S3 Intelligent-Tiering storage class.

The S3 Intelligent-Tiering storage class is the ideal storage class for data with unknown, changing, or unpredictable access patterns, independent of object size or retention period. If the size of an object is less than 128 KB, it is not eligible for auto-tiering. Smaller objects can be stored, but they are always charged at the Frequent Access tier rates in the S3 Intelligent-Tiering storage class.

For more information, see [Storage class for automatically optimizing frequently and infrequently accessed objects].

Operations related to `GetBucketIntelligentTieringConfiguration` include:

  • DeleteBucketIntelligentTieringConfiguration][2
  • PutBucketIntelligentTieringConfiguration][3
  • ListBucketIntelligentTieringConfigurations][4

[1]: docs.aws.amazon.com/AmazonS3/latest/dev/storage-class-intro.html#sc-dynamic-data-access [2]: docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteBucketIntelligentTieringConfiguration.html [3]: docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketIntelligentTieringConfiguration.html [4]: docs.aws.amazon.com/AmazonS3/latest/API/API_ListBucketIntelligentTieringConfigurations.html

Examples:

Request syntax with placeholder values


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

Response structure


resp.intelligent_tiering_configuration.id #=> String
resp.intelligent_tiering_configuration.filter.prefix #=> String
resp.intelligent_tiering_configuration.filter.tag.key #=> String
resp.intelligent_tiering_configuration.filter.tag.value #=> String
resp.intelligent_tiering_configuration.filter.and.prefix #=> String
resp.intelligent_tiering_configuration.filter.and.tags #=> Array
resp.intelligent_tiering_configuration.filter.and.tags[0].key #=> String
resp.intelligent_tiering_configuration.filter.and.tags[0].value #=> String
resp.intelligent_tiering_configuration.status #=> String, one of "Enabled", "Disabled"
resp.intelligent_tiering_configuration.tierings #=> Array
resp.intelligent_tiering_configuration.tierings[0].days #=> Integer
resp.intelligent_tiering_configuration.tierings[0].access_tier #=> String, one of "ARCHIVE_ACCESS", "DEEP_ARCHIVE_ACCESS"

Parameters:

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

    ({})

Options Hash (params):

  • :bucket (required, String)

    The name of the Amazon S3 bucket whose configuration you want to modify or retrieve.

  • :id (required, String)

    The ID used to identify the S3 Intelligent-Tiering configuration.

Returns:

See Also:


3793
3794
3795
3796
# File 'lib/aws-sdk-s3/client.rb', line 3793

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

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

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

To use this operation, you must have permissions to perform the `s3:GetInventoryConfiguration` action. The bucket owner has this permission by default and can grant this permission to others. For more information about permissions, see [Permissions Related to Bucket Subresource Operations] and [Managing Access Permissions to Your Amazon S3 Resources].

For information about the Amazon S3 inventory feature, see [Amazon S3 Inventory].

The following operations are related to `GetBucketInventoryConfiguration`:

  • DeleteBucketInventoryConfiguration][4
  • ListBucketInventoryConfigurations][5
  • PutBucketInventoryConfiguration][6

[1]: docs.aws.amazon.com/AmazonS3/latest/userguide/using-with-s3-actions.html#using-with-s3-actions-related-to-bucket-subresources [2]: docs.aws.amazon.com/AmazonS3/latest/userguide/s3-access-control.html [3]: docs.aws.amazon.com/AmazonS3/latest/dev/storage-inventory.html [4]: docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteBucketInventoryConfiguration.html [5]: docs.aws.amazon.com/AmazonS3/latest/API/API_ListBucketInventoryConfigurations.html [6]: docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketInventoryConfiguration.html

Examples:

Request syntax with placeholder values


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

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", "IntelligentTieringAccessTier", "BucketKeyStatus"
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.

  • :expected_bucket_owner (String)

    The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP `403 (Access Denied)` error.

Returns:

See Also:


3872
3873
3874
3875
# File 'lib/aws-sdk-s3/client.rb', line 3872

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

For an updated version of this API, see [GetBucketLifecycleConfiguration]. If you configured a bucket lifecycle using the `filter` element, you should see the updated version of this topic. This topic is provided for backward compatibility.

Returns the lifecycle configuration information set on the bucket. For information about lifecycle configuration, see [Object Lifecycle Management].

To use this operation, you must have permission to perform the `s3:GetLifecycleConfiguration` action. The bucket owner has this permission by default. The bucket owner can grant this permission to others. For more information about permissions, see [Permissions Related to Bucket Subresource Operations] and [Managing Access Permissions to Your Amazon S3 Resources].

`GetBucketLifecycle` has the following special error:

  • Error code: `NoSuchLifecycleConfiguration`

    • Description: The lifecycle configuration does not exist.

    • HTTP Status Code: 404 Not Found

    • SOAP Fault Code Prefix: Client

The following operations are related to `GetBucketLifecycle`:

  • GetBucketLifecycleConfiguration][1
  • PutBucketLifecycle][5
  • DeleteBucketLifecycle][6

[1]: docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketLifecycleConfiguration.html [2]: docs.aws.amazon.com/AmazonS3/latest/dev/object-lifecycle-mgmt.html [3]: docs.aws.amazon.com/AmazonS3/latest/userguide/using-with-s3-actions.html#using-with-s3-actions-related-to-bucket-subresources [4]: docs.aws.amazon.com/AmazonS3/latest/userguide/s3-access-control.html [5]: docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketLifecycle.html [6]: docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteBucketLifecycle.html

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
  expected_bucket_owner: "AccountId",
})

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", "DEEP_ARCHIVE"
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", "DEEP_ARCHIVE"
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)

    The name of the bucket for which to get the lifecycle information.

  • :expected_bucket_owner (String)

    The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP `403 (Access Denied)` error.

Returns:

See Also:


3984
3985
3986
3987
# File 'lib/aws-sdk-s3/client.rb', line 3984

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

<note markdown=“1”> Bucket lifecycle configuration now supports specifying a lifecycle rule using an object key name prefix, one or more object tags, or a combination of both. Accordingly, this section describes the latest API. The response describes the new filter element that you can use to specify a filter to select a subset of objects to which the rule applies. If you are using a previous version of the lifecycle configuration, it still works. For the earlier action, see [GetBucketLifecycle].

</note>

Returns the lifecycle configuration information set on the bucket. For information about lifecycle configuration, see [Object Lifecycle Management].

To use this operation, you must have permission to perform the `s3:GetLifecycleConfiguration` action. The bucket owner has this permission, by default. The bucket owner can grant this permission to others. For more information about permissions, see [Permissions Related to Bucket Subresource Operations] and [Managing Access Permissions to Your Amazon S3 Resources].

`GetBucketLifecycleConfiguration` has the following special error:

  • Error code: `NoSuchLifecycleConfiguration`

    • Description: The lifecycle configuration does not exist.

    • HTTP Status Code: 404 Not Found

    • SOAP Fault Code Prefix: Client

The following operations are related to `GetBucketLifecycleConfiguration`:

  • GetBucketLifecycle][1
  • PutBucketLifecycle][5
  • DeleteBucketLifecycle][6

[1]: docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketLifecycle.html [2]: docs.aws.amazon.com/AmazonS3/latest/dev/object-lifecycle-mgmt.html [3]: docs.aws.amazon.com/AmazonS3/latest/userguide/using-with-s3-actions.html#using-with-s3-actions-related-to-bucket-subresources [4]: docs.aws.amazon.com/AmazonS3/latest/userguide/s3-access-control.html [5]: docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketLifecycle.html [6]: docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteBucketLifecycle.html

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
  expected_bucket_owner: "AccountId",
})

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", "DEEP_ARCHIVE"
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", "DEEP_ARCHIVE"
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)

    The name of the bucket for which to get the lifecycle information.

  • :expected_bucket_owner (String)

    The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP `403 (Access Denied)` error.

Returns:

See Also:


4114
4115
4116
4117
# File 'lib/aws-sdk-s3/client.rb', line 4114

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. You set the bucket's Region using the `LocationConstraint` request parameter in a `CreateBucket` request. For more information, see [CreateBucket].

To use this implementation of the operation, you must be the bucket owner.

To use this API against an access point, provide the alias of the access point in place of the bucket name.

The following operations are related to `GetBucketLocation`:

  • GetObject][2
  • CreateBucket][1

[1]: docs.aws.amazon.com/AmazonS3/latest/API/API_CreateBucket.html [2]: docs.aws.amazon.com/AmazonS3/latest/API/API_GetObject.html

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
  expected_bucket_owner: "AccountId",
})

Response structure


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

Parameters:

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

    ({})

Options Hash (params):

  • :bucket (required, String)

    The name of the bucket for which to get the location.

  • :expected_bucket_owner (String)

    The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP `403 (Access Denied)` error.

Returns:

See Also:


4181
4182
4183
4184
# File 'lib/aws-sdk-s3/client.rb', line 4181

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.

The following operations are related to `GetBucketLogging`:

  • CreateBucket][1
  • PutBucketLogging][2

[1]: docs.aws.amazon.com/AmazonS3/latest/API/API_CreateBucket.html [2]: docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketLogging.html

Examples:

Request syntax with placeholder values


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

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)

    The bucket name for which to get the logging information.

  • :expected_bucket_owner (String)

    The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP `403 (Access Denied)` error.

Returns:

See Also:


4236
4237
4238
4239
# File 'lib/aws-sdk-s3/client.rb', line 4236

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. Note that this doesn't include the daily storage metrics.

To use this operation, you must have permissions to perform the `s3:GetMetricsConfiguration` action. The bucket owner has this permission by default. The bucket owner can grant this permission to others. For more information about permissions, see [Permissions Related to Bucket Subresource Operations] and [Managing Access Permissions to Your Amazon S3 Resources].

For information about CloudWatch request metrics for Amazon S3, see [Monitoring Metrics with Amazon CloudWatch].

The following operations are related to `GetBucketMetricsConfiguration`:

  • PutBucketMetricsConfiguration][4
  • DeleteBucketMetricsConfiguration][5
  • ListBucketMetricsConfigurations][6
  • Monitoring Metrics with Amazon CloudWatch][3

[1]: docs.aws.amazon.com/AmazonS3/latest/userguide/using-with-s3-actions.html#using-with-s3-actions-related-to-bucket-subresources [2]: docs.aws.amazon.com/AmazonS3/latest/userguide/s3-access-control.html [3]: docs.aws.amazon.com/AmazonS3/latest/dev/cloudwatch-monitoring.html [4]: docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketMetricsConfiguration.html [5]: docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteBucketMetricsConfiguration.html [6]: docs.aws.amazon.com/AmazonS3/latest/API/API_ListBucketMetricsConfigurations.html

Examples:

Request syntax with placeholder values


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

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.access_point_arn #=> 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
resp.metrics_configuration.filter.and.access_point_arn #=> 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.

  • :expected_bucket_owner (String)

    The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP `403 (Access Denied)` error.

Returns:

See Also:


4316
4317
4318
4319
# File 'lib/aws-sdk-s3/client.rb', line 4316

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

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
  expected_bucket_owner: "AccountId",
})

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:*", "s3:ObjectRestore:Post", "s3:ObjectRestore:Completed", "s3:Replication:*", "s3:Replication:OperationFailedReplication", "s3:Replication:OperationNotTracked", "s3:Replication:OperationMissedThreshold", "s3:Replication:OperationReplicatedAfterThreshold"
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:*", "s3:ObjectRestore:Post", "s3:ObjectRestore:Completed", "s3:Replication:*", "s3:Replication:OperationFailedReplication", "s3:Replication:OperationNotTracked", "s3:Replication:OperationMissedThreshold", "s3:Replication:OperationReplicatedAfterThreshold"
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:*", "s3:ObjectRestore:Post", "s3:ObjectRestore:Completed", "s3:Replication:*", "s3:Replication:OperationFailedReplication", "s3:Replication:OperationNotTracked", "s3:Replication:OperationMissedThreshold", "s3:Replication:OperationReplicatedAfterThreshold"
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:*", "s3:ObjectRestore:Post", "s3:ObjectRestore:Completed", "s3:Replication:*", "s3:Replication:OperationFailedReplication", "s3:Replication:OperationNotTracked", "s3:Replication:OperationMissedThreshold", "s3:Replication:OperationReplicatedAfterThreshold"
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:*", "s3:ObjectRestore:Post", "s3:ObjectRestore:Completed", "s3:Replication:*", "s3:Replication:OperationFailedReplication", "s3:Replication:OperationNotTracked", "s3:Replication:OperationMissedThreshold", "s3:Replication:OperationReplicatedAfterThreshold"
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:*", "s3:ObjectRestore:Post", "s3:ObjectRestore:Completed", "s3:Replication:*", "s3:Replication:OperationFailedReplication", "s3:Replication:OperationNotTracked", "s3:Replication:OperationMissedThreshold", "s3:Replication:OperationReplicatedAfterThreshold"
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)

    The name of the bucket for which to get the notification configuration.

  • :expected_bucket_owner (String)

    The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP `403 (Access Denied)` error.

Returns:

See Also:


4429
4430
4431
4432
# File 'lib/aws-sdk-s3/client.rb', line 4429

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.

If notifications are not enabled on the bucket, the action returns an empty `NotificationConfiguration` element.

By default, you must be the bucket owner to read the notification configuration of a bucket. However, the bucket owner can use a bucket policy to grant permission to other users to read this configuration with the `s3:GetBucketNotification` permission.

For more information about setting and reading the notification configuration on a bucket, see [Setting Up Notification of Bucket Events]. For more information about bucket policies, see [Using Bucket Policies].

The following action is related to `GetBucketNotification`:

  • PutBucketNotification][3

^

[1]: docs.aws.amazon.com/AmazonS3/latest/dev/NotificationHowTo.html [2]: docs.aws.amazon.com/AmazonS3/latest/dev/using-iam-policies.html [3]: docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketNotification.html

Examples:

Request syntax with placeholder values


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

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:*", "s3:ObjectRestore:Post", "s3:ObjectRestore:Completed", "s3:Replication:*", "s3:Replication:OperationFailedReplication", "s3:Replication:OperationNotTracked", "s3:Replication:OperationMissedThreshold", "s3:Replication:OperationReplicatedAfterThreshold"
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:*", "s3:ObjectRestore:Post", "s3:ObjectRestore:Completed", "s3:Replication:*", "s3:Replication:OperationFailedReplication", "s3:Replication:OperationNotTracked", "s3:Replication:OperationMissedThreshold", "s3:Replication:OperationReplicatedAfterThreshold"
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:*", "s3:ObjectRestore:Post", "s3:ObjectRestore:Completed", "s3:Replication:*", "s3:Replication:OperationFailedReplication", "s3:Replication:OperationNotTracked", "s3:Replication:OperationMissedThreshold", "s3:Replication:OperationReplicatedAfterThreshold"
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)

    The name of the bucket for which to get the notification configuration.

  • :expected_bucket_owner (String)

    The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP `403 (Access Denied)` error.

Returns:

See Also:


4514
4515
4516
4517
# File 'lib/aws-sdk-s3/client.rb', line 4514

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

#get_bucket_ownership_controls(params = {}) ⇒ Types::GetBucketOwnershipControlsOutput

Retrieves `OwnershipControls` for an Amazon S3 bucket. To use this operation, you must have the `s3:GetBucketOwnershipControls` permission. For more information about Amazon S3 permissions, see [Specifying Permissions in a Policy].

For information about Amazon S3 Object Ownership, see [Using Object Ownership].

The following operations are related to `GetBucketOwnershipControls`:

  • PutBucketOwnershipControls

  • DeleteBucketOwnershipControls

[1]: docs.aws.amazon.com/AmazonS3/latest/dev/using-with-s3-actions.html [2]: docs.aws.amazon.com/AmazonS3/latest/dev/about-object-ownership.html

Examples:

Request syntax with placeholder values


resp = client.get_bucket_ownership_controls({
  bucket: "BucketName", # required
  expected_bucket_owner: "AccountId",
})

Response structure


resp.ownership_controls.rules #=> Array
resp.ownership_controls.rules[0].object_ownership #=> String, one of "BucketOwnerPreferred", "ObjectWriter"

Parameters:

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

    ({})

Options Hash (params):

  • :bucket (required, String)

    The name of the Amazon S3 bucket whose `OwnershipControls` you want to retrieve.

  • :expected_bucket_owner (String)

    The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP `403 (Access Denied)` error.

Returns:

See Also:


4567
4568
4569
4570
# File 'lib/aws-sdk-s3/client.rb', line 4567

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

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

Returns the policy of a specified bucket. If you are using an identity other than the root user of the Amazon Web Services account that owns the bucket, the calling identity must have the `GetBucketPolicy` permissions on the specified bucket and belong to the bucket owner's account in order to use this operation.

If you don't have `GetBucketPolicy` permissions, Amazon S3 returns a `403 Access Denied` error. If you have the correct permissions, but you're not using an identity that belongs to the bucket owner's account, Amazon S3 returns a `405 Method Not Allowed` error.

As a security precaution, the root user of the Amazon Web Services account that owns a bucket can always use this operation, even if the policy explicitly denies the root user the ability to perform this action.

For more information about bucket policies, see [Using Bucket Policies and User Policies].

The following action is related to `GetBucketPolicy`:

  • GetObject][2

^

[1]: docs.aws.amazon.com/AmazonS3/latest/dev/using-iam-policies.html [2]: docs.aws.amazon.com/AmazonS3/latest/API/API_GetObject.html

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
  expected_bucket_owner: "AccountId",
})

Response structure


resp.policy #=> String

Parameters:

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

    ({})

Options Hash (params):

  • :bucket (required, String)

    The bucket name for which to get the bucket policy.

  • :expected_bucket_owner (String)

    The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP `403 (Access Denied)` error.

Returns:

See Also:


4643
4644
4645
4646
# File 'lib/aws-sdk-s3/client.rb', line 4643

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. In order to use this operation, you must have the `s3:GetBucketPolicyStatus` permission. For more information about Amazon S3 permissions, see [Specifying Permissions in a Policy].

For more information about when Amazon S3 considers a bucket public, see [The Meaning of “Public”].

The following operations are related to `GetBucketPolicyStatus`:

  • Using Amazon S3 Block Public Access][3
  • GetPublicAccessBlock][4
  • PutPublicAccessBlock][5
  • DeletePublicAccessBlock][6

[1]: docs.aws.amazon.com/AmazonS3/latest/dev/using-with-s3-actions.html [2]: docs.aws.amazon.com/AmazonS3/latest/dev/access-control-block-public-access.html#access-control-block-public-access-policy-status [3]: docs.aws.amazon.com/AmazonS3/latest/dev/access-control-block-public-access.html [4]: docs.aws.amazon.com/AmazonS3/latest/API/API_GetPublicAccessBlock.html [5]: docs.aws.amazon.com/AmazonS3/latest/API/API_PutPublicAccessBlock.html [6]: docs.aws.amazon.com/AmazonS3/latest/API/API_DeletePublicAccessBlock.html

Examples:

Request syntax with placeholder values


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

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.

  • :expected_bucket_owner (String)

    The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP `403 (Access Denied)` error.

Returns:

See Also:


4704
4705
4706
4707
# File 'lib/aws-sdk-s3/client.rb', line 4704

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>

For information about replication configuration, see [Replication] in the *Amazon S3 User Guide*.

This action requires permissions for the `s3:GetReplicationConfiguration` action. For more information about permissions, see [Using Bucket Policies and User Policies].

If you include the `Filter` element in a replication configuration, you must also include the `DeleteMarkerReplication` and `Priority` elements. The response also returns those elements.

For information about `GetBucketReplication` errors, see [List of replication-related error codes]

The following operations are related to `GetBucketReplication`:

  • PutBucketReplication][4
  • DeleteBucketReplication][5

[1]: docs.aws.amazon.com/AmazonS3/latest/dev/replication.html [2]: docs.aws.amazon.com/AmazonS3/latest/dev/using-iam-policies.html [3]: docs.aws.amazon.com/AmazonS3/latest/API/ErrorResponses.html#ReplicationErrorCodeList [4]: docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketReplication.html [5]: docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteBucketReplication.html

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
  expected_bucket_owner: "AccountId",
})

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].source_selection_criteria.replica_modifications.status #=> String, one of "Enabled", "Disabled"
resp.replication_configuration.rules[0].existing_object_replication.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", "DEEP_ARCHIVE", "OUTPOSTS"
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].destination.replication_time.status #=> String, one of "Enabled", "Disabled"
resp.replication_configuration.rules[0].destination.replication_time.time.minutes #=> Integer
resp.replication_configuration.rules[0].destination.metrics.status #=> String, one of "Enabled", "Disabled"
resp.replication_configuration.rules[0].destination.metrics.event_threshold.minutes #=> Integer
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)

    The bucket name for which to get the replication information.

  • :expected_bucket_owner (String)

    The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP `403 (Access Denied)` error.

Returns:

See Also:


4823
4824
4825
4826
# File 'lib/aws-sdk-s3/client.rb', line 4823

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. To use this version of the operation, you must be the bucket owner. For more information, see [Requester Pays Buckets].

The following operations are related to `GetBucketRequestPayment`:

  • ListObjects][2

^

[1]: docs.aws.amazon.com/AmazonS3/latest/dev/RequesterPaysBuckets.html [2]: docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjects.html

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
  expected_bucket_owner: "AccountId",
})

Response structure


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

Parameters:

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

    ({})

Options Hash (params):

  • :bucket (required, String)

    The name of the bucket for which to get the payment request configuration

  • :expected_bucket_owner (String)

    The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP `403 (Access Denied)` error.

Returns:

See Also:


4885
4886
4887
4888
# File 'lib/aws-sdk-s3/client.rb', line 4885

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.

To use this operation, you must have permission to perform the `s3:GetBucketTagging` action. By default, the bucket owner has this permission and can grant this permission to others.

`GetBucketTagging` has the following special error:

  • Error code: `NoSuchTagSetError`

    • Description: There is no tag set associated with the bucket.

    ^

The following operations are related to `GetBucketTagging`:

  • PutBucketTagging][1
  • DeleteBucketTagging][2

[1]: docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketTagging.html [2]: docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteBucketTagging.html

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
  expected_bucket_owner: "AccountId",
})

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)

    The name of the bucket for which to get the tagging information.

  • :expected_bucket_owner (String)

    The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP `403 (Access Denied)` error.

Returns:

See Also:


4967
4968
4969
4970
# File 'lib/aws-sdk-s3/client.rb', line 4967

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.

To retrieve the versioning state of a bucket, you must be the bucket owner.

This implementation also returns the MFA Delete status of the versioning state. If the MFA Delete status is `enabled`, the bucket owner must use an authentication device to change the versioning state of the bucket.

The following operations are related to `GetBucketVersioning`:

  • GetObject][1
  • PutObject][2
  • DeleteObject][3

[1]: docs.aws.amazon.com/AmazonS3/latest/API/API_GetObject.html [2]: docs.aws.amazon.com/AmazonS3/latest/API/API_PutObject.html [3]: docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteObject.html

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
  expected_bucket_owner: "AccountId",
})

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)

    The name of the bucket for which to get the versioning information.

  • :expected_bucket_owner (String)

    The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP `403 (Access Denied)` error.

Returns:

See Also:


5040
5041
5042
5043
# File 'lib/aws-sdk-s3/client.rb', line 5040

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. To host website on Amazon S3, you can configure a bucket as website by adding a website configuration. For more information about hosting websites, see [Hosting Websites on Amazon S3].

This GET action requires the `S3:GetBucketWebsite` permission. By default, only the bucket owner can read the bucket website configuration. However, bucket owners can allow other users to read the website configuration by writing a bucket policy granting them the `S3:GetBucketWebsite` permission.

The following operations are related to `DeleteBucketWebsite`:

  • DeleteBucketWebsite][2
  • PutBucketWebsite][3

[1]: docs.aws.amazon.com/AmazonS3/latest/dev/WebsiteHosting.html [2]: docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteBucketWebsite.html [3]: docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketWebsite.html

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
  expected_bucket_owner: "AccountId",
})

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)

    The bucket name for which to get the website configuration.

  • :expected_bucket_owner (String)

    The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP `403 (Access Denied)` error.

Returns:

See Also:


5128
5129
5130
5131
# File 'lib/aws-sdk-s3/client.rb', line 5128

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. To use `GET`, you must have `READ` access to the object. If you grant `READ` access to the anonymous user, you can return the object without using an authorization header.

An Amazon S3 bucket has no directory hierarchy such as you would find in a typical computer file system. You can, however, create a logical hierarchy by using object key names that imply a folder structure. For example, instead of naming an object `sample.jpg`, you can name it `photos/2006/February/sample.jpg`.

To get an object from such a logical hierarchy, specify the full key name for the object in the `GET` operation. For a virtual hosted-style request example, if you have the object `photos/2006/February/sample.jpg`, specify the resource as `/photos/2006/February/sample.jpg`. For a path-style request example, if you have the object `photos/2006/February/sample.jpg` in the bucket named `examplebucket`, specify the resource as `/examplebucket/photos/2006/February/sample.jpg`. For more information about request types, see [HTTP Host Header Bucket Specification].

To distribute large files to many people, you can save bandwidth costs by using BitTorrent. For more information, see [Amazon S3 Torrent]. For more information about returning the ACL of an object, see [GetObjectAcl].

If the object you are retrieving is stored in the S3 Glacier or S3 Glacier Deep Archive storage class, or S3 Intelligent-Tiering Archive or S3 Intelligent-Tiering Deep Archive tiers, before you can retrieve the object you must first restore a copy using [RestoreObject]. Otherwise, this action returns an `InvalidObjectStateError` error. For information about restoring archived objects, see [Restoring Archived Objects].

Encryption request headers, like `x-amz-server-side-encryption`, should not be sent for GET requests if your object uses server-side encryption with KMS keys (SSE-KMS) or server-side encryption with Amazon S3–managed encryption keys (SSE-S3). If your object does use these types of keys, you’ll get an HTTP 400 BadRequest error.

If you encrypt an object by using server-side encryption with customer-provided encryption keys (SSE-C) when you store the object in Amazon S3, then when you GET the object, you must use the following headers:

  • x-amz-server-side-encryption-customer-algorithm

  • x-amz-server-side-encryption-customer-key

  • x-amz-server-side-encryption-customer-key-MD5

For more information about SSE-C, see [Server-Side Encryption (Using Customer-Provided Encryption Keys)].

Assuming you have the relevant permission to read object tags, the response also returns the `x-amz-tagging-count` header that provides the count of number of tags associated with the object. You can use

GetObjectTagging][7

to retrieve the tag set associated with an

object.

Permissions

You need the relevant read object (or version) permission for this operation. For more information, see [Specifying Permissions in a Policy]. If the object you request does not exist, the error Amazon S3 returns depends on whether you also have the `s3:ListBucket` permission.

  • If you have the `s3:ListBucket` permission on the bucket, Amazon S3 will return an HTTP status code 404 (“no such key”) error.

  • If you don’t have the `s3:ListBucket` permission, Amazon S3 will return an HTTP status code 403 (“access denied”) error.

Versioning

By default, the GET action returns the current version of an object. To return a different version, use the `versionId` subresource.

<note markdown=“1”> * You need the `s3:GetObjectVersion` permission to access a specific

version of an object.
  • If the current version of the object is a delete marker, Amazon S3 behaves as if the object was deleted and includes `x-amz-delete-marker: true` in the response.

</note>

For more information about versioning, see [PutBucketVersioning].

**Overriding Response Header Values**

There are times when you want to override certain response header values in a GET response. For example, you might override the Content-Disposition response header value in your GET request.

You can override values for a set of response headers using the following query parameters. These response header values are sent only on a successful request, that is, when status code 200 OK is returned. The set of headers you can override using these parameters is a subset of the headers that Amazon S3 accepts when you create an object. The response headers that you can override for the GET response are `Content-Type`, `Content-Language`, `Expires`, `Cache-Control`, `Content-Disposition`, and `Content-Encoding`. To override these header values in the GET response, you use the following request parameters.

<note markdown=“1”> You must sign the request, either using an Authorization header or a presigned URL, when using these parameters. They cannot be used with an unsigned (anonymous) request.

</note>
  • `response-content-type`

  • `response-content-language`

  • `response-expires`

  • `response-cache-control`

  • `response-content-disposition`

  • `response-content-encoding`

**Additional Considerations about Request Headers**

If both of the `If-Match` and `If-Unmodified-Since` headers are present in the request as follows: `If-Match` condition evaluates to `true`, and; `If-Unmodified-Since` condition evaluates to `false`; then, S3 returns 200 OK and the data requested.

If both of the `If-None-Match` and `If-Modified-Since` headers are present in the request as follows:` If-None-Match` condition evaluates to `false`, and; `If-Modified-Since` condition evaluates to `true`; then, S3 returns 304 Not Modified response code.

For more information about conditional requests, see [RFC 7232].

The following operations are related to `GetObject`:

  • ListBuckets][11
  • GetObjectAcl][3

[1]: docs.aws.amazon.com/AmazonS3/latest/dev/VirtualHosting.html#VirtualHostingSpecifyBucket [2]: docs.aws.amazon.com/AmazonS3/latest/dev/S3Torrent.html [3]: docs.aws.amazon.com/AmazonS3/latest/API/API_GetObjectAcl.html [4]: docs.aws.amazon.com/AmazonS3/latest/API/API_RestoreObject.html [5]: docs.aws.amazon.com/AmazonS3/latest/dev/restoring-objects.html [6]: docs.aws.amazon.com/AmazonS3/latest/dev/ServerSideEncryptionCustomerKeys.html [7]: docs.aws.amazon.com/AmazonS3/latest/API/API_GetObjectTagging.html [8]: docs.aws.amazon.com/AmazonS3/latest/dev/using-with-s3-actions.html [9]: docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketVersioning.html [10]: tools.ietf.org/html/rfc7232 [11]: docs.aws.amazon.com/AmazonS3/latest/API/API_ListBuckets.html

Examples:

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", 
}

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", 
}

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
# However truncation of the body will be retried automatically using a range request
File.open('/path/to/file', 'wb') do |file|
  s3.get_object(bucket: 'bucket-name', key: 'object-key') do |chunk, headers|
    # headers['content-length']
    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,
  expected_bucket_owner: "AccountId",
})

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.bucket_key_enabled #=> Boolean
resp.storage_class #=> String, one of "STANDARD", "REDUCED_REDUNDANCY", "STANDARD_IA", "ONEZONE_IA", "INTELLIGENT_TIERING", "GLACIER", "DEEP_ARCHIVE", "OUTPOSTS"
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)

    The bucket name containing the object.

    When using this action with an access point, you must direct requests to the access point hostname. The access point hostname takes the form AccessPointName-AccountId.s3-accesspoint.Region.amazonaws.com. When using this action with an access point through the Amazon Web Services SDKs, you provide the access point ARN in place of the bucket name. For more information about access point ARNs, see [Using access points] in the *Amazon S3 User Guide*.

    When using an Object Lambda access point the hostname takes the form AccessPointName-AccountId.s3-object-lambda.Region.amazonaws.com.

    When using this action with Amazon S3 on Outposts, you must direct requests to the S3 on Outposts hostname. The S3 on Outposts hostname takes the form AccessPointName-AccountId.outpostID.s3-outposts.Region.amazonaws.com. When using this action using S3 on Outposts through the Amazon Web Services SDKs, you provide the Outposts bucket ARN in place of the bucket name. For more information about S3 on Outposts ARNs, see

    Using S3 on Outposts][2

    in the *Amazon S3 User Guide*.

    [1]: docs.aws.amazon.com/AmazonS3/latest/userguide/using-access-points.html [2]: docs.aws.amazon.com/AmazonS3/latest/userguide/S3onOutposts.html

  • :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)

    Key of the object to get.

  • :range (String)

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

    <note markdown=“1”> Amazon S3 doesn't support retrieving multiple ranges of data per `GET` request.

    </note>
    

    [1]: 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 decrypting the object (for example, AES256).

  • :sse_customer_key (String)

    Specifies the customer-provided encryption key for Amazon S3 used to encrypt the data. This value is used to decrypt the object when recovering it and must match the one used when storing the data. 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 that the encryption key was transmitted without error.

  • :request_payer (String)

    Confirms that the requester knows that they will be charged for the request. Bucket owners need not specify this parameter in their requests. For information about downloading objects from requester pays buckets, see [Downloading Objects in Requestor Pays Buckets] in the *Amazon S3 User Guide*.

    [1]: 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.

  • :expected_bucket_owner (String)

    The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP `403 (Access Denied)` error.

Returns:

See Also:


5592
5593
5594
5595
# File 'lib/aws-sdk-s3/client.rb', line 5592

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. To use this operation, you must have `READ_ACP` access to the object.

This action is not supported by Amazon S3 on Outposts.

Versioning

By default, GET returns ACL information about the current version of an object. To return ACL information about a different version, use the versionId subresource.

The following operations are related to `GetObjectAcl`:

  • GetObject][1
  • DeleteObject][2
  • PutObject][3

[1]: docs.aws.amazon.com/AmazonS3/latest/API/API_GetObject.html [2]: docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteObject.html [3]: docs.aws.amazon.com/AmazonS3/latest/API/API_PutObject.html

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
  expected_bucket_owner: "AccountId",
})

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)

    The bucket name that contains the object for which to get the ACL information.

    When using this action with an access point, you must direct requests to the access point hostname. The access point hostname takes the form AccessPointName-AccountId.s3-accesspoint.Region.amazonaws.com. When using this action with an access point through the Amazon Web Services SDKs, you provide the access point ARN in place of the bucket name. For more information about access point ARNs, see [Using access points] in the *Amazon S3 User Guide*.

    [1]: docs.aws.amazon.com/AmazonS3/latest/userguide/using-access-points.html

  • :key (required, String)

    The key of the object for which to get the ACL information.

  • :version_id (String)

    VersionId used to reference a specific version of the object.

  • :request_payer (String)

    Confirms that the requester knows that they will be charged for the request. Bucket owners need not specify this parameter in their requests. For information about downloading objects from requester pays buckets, see [Downloading Objects in Requestor Pays Buckets] in the *Amazon S3 User Guide*.

    [1]: docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html

  • :expected_bucket_owner (String)

    The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP `403 (Access Denied)` error.

Returns:

See Also:


5745
5746
5747
5748
# File 'lib/aws-sdk-s3/client.rb', line 5745

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. For more information, see [Locking Objects].

This action is not supported by Amazon S3 on Outposts.

[1]: docs.aws.amazon.com/AmazonS3/latest/dev/object-lock.html

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
  expected_bucket_owner: "AccountId",
})

Response structure


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

Parameters:

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

    ({})

Options Hash (params):

  • :bucket (required, String)

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

    When using this action with an access point, you must direct requests to the access point hostname. The access point hostname takes the form AccessPointName-AccountId.s3-accesspoint.Region.amazonaws.com. When using this action with an access point through the Amazon Web Services SDKs, you provide the access point ARN in place of the bucket name. For more information about access point ARNs, see [Using access points] in the *Amazon S3 User Guide*.

    [1]: docs.aws.amazon.com/AmazonS3/latest/userguide/using-access-points.html

  • :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 they will be charged for the request. Bucket owners need not specify this parameter in their requests. For information about downloading objects from requester pays buckets, see [Downloading Objects in Requestor Pays Buckets] in the *Amazon S3 User Guide*.

    [1]: docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html

  • :expected_bucket_owner (String)

    The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP `403 (Access Denied)` error.

Returns:

See Also:


5821
5822
5823
5824
# File 'lib/aws-sdk-s3/client.rb', line 5821

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. For more information, see [Locking Objects].

[1]: docs.aws.amazon.com/AmazonS3/latest/dev/object-lock.html

Examples:

Request syntax with placeholder values


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

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.

    When using this action with an access point, you must direct requests to the access point hostname. The access point hostname takes the form AccessPointName-AccountId.s3-accesspoint.Region.amazonaws.com. When using this action with an access point through the Amazon Web Services SDKs, you provide the access point ARN in place of the bucket name. For more information about access point ARNs, see [Using access points] in the *Amazon S3 User Guide*.

    [1]: docs.aws.amazon.com/AmazonS3/latest/userguide/using-access-points.html

  • :expected_bucket_owner (String)

    The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP `403 (Access Denied)` error.

Returns:

See Also:


5877
5878
5879
5880
# File 'lib/aws-sdk-s3/client.rb', line 5877

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. For more information, see [Locking Objects].

This action is not supported by Amazon S3 on Outposts.

[1]: docs.aws.amazon.com/AmazonS3/latest/dev/object-lock.html

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
  expected_bucket_owner: "AccountId",
})

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 name containing the object whose retention settings you want to retrieve.

    When using this action with an access point, you must direct requests to the access point hostname. The access point hostname takes the form AccessPointName-AccountId.s3-accesspoint.Region.amazonaws.com. When using this action with an access point through the Amazon Web Services SDKs, you provide the access point ARN in place of the bucket name. For more information about access point ARNs, see [Using access points] in the *Amazon S3 User Guide*.

    [1]: docs.aws.amazon.com/AmazonS3/latest/userguide/using-access-points.html

  • :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 they will be charged for the request. Bucket owners need not specify this parameter in their requests. For information about downloading objects from requester pays buckets, see [Downloading Objects in Requestor Pays Buckets] in the *Amazon S3 User Guide*.

    [1]: docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html

  • :expected_bucket_owner (String)

    The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP `403 (Access Denied)` error.

Returns:

See Also:


5954
5955
5956
5957
# File 'lib/aws-sdk-s3/client.rb', line 5954

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. You send the GET request against the tagging subresource associated with the object.

To use this operation, you must have permission to perform the `s3:GetObjectTagging` action. By default, the GET action returns information about current version of an object. For a versioned bucket, you can have multiple versions of an object in your bucket. To retrieve tags of any other version, use the versionId query parameter. You also need permission for the `s3:GetObjectVersionTagging` action.

By default, the bucket owner has this permission and can grant this permission to others.

For information about the Amazon S3 object tagging feature, see [Object Tagging].

The following action is related to `GetObjectTagging`:

  • PutObjectTagging][2
  • DeleteObjectTagging][3

[1]: docs.aws.amazon.com/AmazonS3/latest/dev/object-tagging.html [2]: docs.aws.amazon.com/AmazonS3/latest/API/API_PutObjectTagging.html [3]: docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteObjectTagging.html

Examples:

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", 
}

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", 
}

Request syntax with placeholder values


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

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)

    The bucket name containing the object for which to get the tagging information.

    When using this action with an access point, you must direct requests to the access point hostname. The access point hostname takes the form AccessPointName-AccountId.s3-accesspoint.Region.amazonaws.com. When using this action with an access point through the Amazon Web Services SDKs, you provide the access point ARN in place of the bucket name. For more information about access point ARNs, see [Using access points] in the *Amazon S3 User Guide*.

    When using this action with Amazon S3 on Outposts, you must direct requests to the S3 on Outposts hostname. The S3 on Outposts hostname takes the form AccessPointName-AccountId.outpostID.s3-outposts.Region.amazonaws.com. When using this action using S3 on Outposts through the Amazon Web Services SDKs, you provide the Outposts bucket ARN in place of the bucket name. For more information about S3 on Outposts ARNs, see

    Using S3 on Outposts][2

    in the *Amazon S3 User Guide*.

    [1]: docs.aws.amazon.com/AmazonS3/latest/userguide/using-access-points.html [2]: docs.aws.amazon.com/AmazonS3/latest/userguide/S3onOutposts.html

  • :key (required, String)

    Object key for which to get the tagging information.

  • :version_id (String)

    The versionId of the object for which to get the tagging information.

  • :expected_bucket_owner (String)

    The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP `403 (Access Denied)` error.

  • :request_payer (String)

    Confirms that the requester knows that they will be charged for the request. Bucket owners need not specify this parameter in their requests. For information about downloading objects from requester pays buckets, see [Downloading Objects in Requestor Pays Buckets] in the *Amazon S3 User Guide*.

    [1]: docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html

Returns:

See Also:


6107
6108
6109
6110
# File 'lib/aws-sdk-s3/client.rb', line 6107

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

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

Returns torrent files from a bucket. BitTorrent can save you bandwidth when you're distributing large files. For more information about BitTorrent, see [Using BitTorrent with Amazon S3].

<note markdown=“1”> You can get torrent only for objects that are less than 5 GB in size, and that are not encrypted using server-side encryption with a customer-provided encryption key.

</note>

To use GET, you must have READ access to the object.

This action is not supported by Amazon S3 on Outposts.

The following action is related to `GetObjectTorrent`:

  • GetObject][2

^

[1]: docs.aws.amazon.com/AmazonS3/latest/dev/S3Torrent.html [2]: docs.aws.amazon.com/AmazonS3/latest/API/API_GetObject.html

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
  expected_bucket_owner: "AccountId",
})

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)

    The name of the bucket containing the object for which to get the torrent files.

  • :key (required, String)

    The object key for which to get the information.

  • :request_payer (String)

    Confirms that the requester knows that they will be charged for the request. Bucket owners need not specify this parameter in their requests. For information about downloading objects from requester pays buckets, see [Downloading Objects in Requestor Pays Buckets] in the *Amazon S3 User Guide*.

    [1]: docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html

  • :expected_bucket_owner (String)

    The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP `403 (Access Denied)` error.

Returns:

See Also:


6200
6201
6202
6203
# File 'lib/aws-sdk-s3/client.rb', line 6200

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. To use this operation, you must have the `s3:GetBucketPublicAccessBlock` permission. For more information about Amazon S3 permissions, see [Specifying Permissions in a Policy].

When Amazon S3 evaluates the `PublicAccessBlock` configuration for a bucket or an object, it checks the `PublicAccessBlock` configuration for both the bucket (or the bucket that contains the object) and the bucket owner's account. If the `PublicAccessBlock` settings are different between the bucket and the account, Amazon S3 uses the most restrictive combination of the bucket-level and account-level settings.

For more information about when Amazon S3 considers a bucket or an object public, see [The Meaning of “Public”].

The following operations are related to `GetPublicAccessBlock`:

  • Using Amazon S3 Block Public Access][3
  • PutPublicAccessBlock][4
  • GetPublicAccessBlock][5
  • DeletePublicAccessBlock][6

[1]: docs.aws.amazon.com/AmazonS3/latest/dev/using-with-s3-actions.html [2]: docs.aws.amazon.com/AmazonS3/latest/dev/access-control-block-public-access.html#access-control-block-public-access-policy-status [3]: docs.aws.amazon.com/AmazonS3/latest/dev/access-control-block-public-access.html [4]: docs.aws.amazon.com/AmazonS3/latest/API/API_PutPublicAccessBlock.html [5]: docs.aws.amazon.com/AmazonS3/latest/API/API_GetPublicAccessBlock.html [6]: docs.aws.amazon.com/AmazonS3/latest/API/API_DeletePublicAccessBlock.html

Examples:

Request syntax with placeholder values


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

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.

  • :expected_bucket_owner (String)

    The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP `403 (Access Denied)` error.

Returns:

See Also:


6271
6272
6273
6274
# File 'lib/aws-sdk-s3/client.rb', line 6271

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 action is useful to determine if a bucket exists and you have permission to access it. The action returns a `200 OK` if the bucket exists and you have permission to access it.

If the bucket does not exist or you do not have permission to access it, the `HEAD` request returns a generic `404 Not Found` or `403 Forbidden` code. A message body is not included, so you cannot determine the exception beyond these error codes.

To use this operation, you must have permissions to perform the `s3:ListBucket` action. The bucket owner has this permission by default and can grant this permission to others. For more information about permissions, see [Permissions Related to Bucket Subresource Operations] and [Managing Access Permissions to Your Amazon S3 Resources].

To use this API against an access point, you must provide the alias of the access point in place of the bucket name or specify the access point ARN. When using the access point ARN, you must direct requests to the access point hostname. The access point hostname takes the form AccessPointName-AccountId.s3-accesspoint.Region.amazonaws.com. When using the Amazon Web Services SDKs, you provide the ARN in place of the bucket name. For more information see, [Using access points].

[1]: docs.aws.amazon.com/AmazonS3/latest/userguide/using-with-s3-actions.html#using-with-s3-actions-related-to-bucket-subresources [2]: docs.aws.amazon.com/AmazonS3/latest/userguide/s3-access-control.html [3]: docs.aws.amazon.com/AmazonS3/latest/userguide/using-access-points.html

The following waiters are defined for this operation (see #wait_until for detailed usage):

* bucket_exists
* bucket_not_exists

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
  expected_bucket_owner: "AccountId",
})

Parameters:

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

    ({})

Options Hash (params):

  • :bucket (required, String)

    The bucket name.

    When using this action with an access point, you must direct requests to the access point hostname. The access point hostname takes the form AccessPointName-AccountId.s3-accesspoint.Region.amazonaws.com. When using this action with an access point through the Amazon Web Services SDKs, you provide the access point ARN in place of the bucket name. For more information about access point ARNs, see [Using access points] in the *Amazon S3 User Guide*.

    When using this action with Amazon S3 on Outposts, you must direct requests to the S3 on Outposts hostname. The S3 on Outposts hostname takes the form AccessPointName-AccountId.outpostID.s3-outposts.Region.amazonaws.com. When using this action using S3 on Outposts through the Amazon Web Services SDKs, you provide the Outposts bucket ARN in place of the bucket name. For more information about S3 on Outposts ARNs, see

    Using S3 on Outposts][2

    in the *Amazon S3 User Guide*.

    [1]: docs.aws.amazon.com/AmazonS3/latest/userguide/using-access-points.html [2]: docs.aws.amazon.com/AmazonS3/latest/userguide/S3onOutposts.html

  • :expected_bucket_owner (String)

    The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP `403 (Access Denied)` error.

Returns:

  • (Struct)

    Returns an empty response.

See Also:


6364
6365
6366
6367
# File 'lib/aws-sdk-s3/client.rb', line 6364

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

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

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

A `HEAD` request has the same options as a `GET` action on an object. The response is identical to the `GET` response except that there is no response body. Because of this, if the `HEAD` request generates an error, it returns a generic `404 Not Found` or `403 Forbidden` code. It is not possible to retrieve the exact exception beyond these error codes.

If you encrypt an object by using server-side encryption with customer-provided encryption keys (SSE-C) when you store the object in Amazon S3, then when you retrieve the metadata from the object, you must use the following headers:

  • x-amz-server-side-encryption-customer-algorithm

  • x-amz-server-side-encryption-customer-key

  • x-amz-server-side-encryption-customer-key-MD5

For more information about SSE-C, see [Server-Side Encryption (Using Customer-Provided Encryption Keys)].

<note markdown=“1”> * Encryption request headers, like `x-amz-server-side-encryption`,

should not be sent for GET requests if your object uses server-side
encryption with KMS keys (SSE-KMS) or server-side encryption with
Amazon S3–managed encryption keys (SSE-S3). If your object does use
these types of keys, you’ll get an HTTP 400 BadRequest error.
  • The last modified property in this case is the creation date of the object.

</note>

Request headers are limited to 8 KB in size. For more information, see [Common Request Headers].

Consider the following when using request headers:

  • Consideration 1 – If both of the `If-Match` and `If-Unmodified-Since` headers are present in the request as follows:

    • `If-Match` condition evaluates to `true`, and;

    • `If-Unmodified-Since` condition evaluates to `false`;

    Then Amazon S3 returns `200 OK` and the data requested.

  • Consideration 2 – If both of the `If-None-Match` and `If-Modified-Since` headers are present in the request as follows:

    • `If-None-Match` condition evaluates to `false`, and;

    • `If-Modified-Since` condition evaluates to `true`;

    Then Amazon S3 returns the `304 Not Modified` response code.

For more information about conditional requests, see [RFC 7232].

Permissions

You need the relevant read object (or version) permission for this operation. For more information, see [Specifying Permissions in a Policy]. If the object you request does not exist, the error Amazon S3 returns depends on whether you also have the s3:ListBucket permission.

  • If you have the `s3:ListBucket` permission on the bucket, Amazon S3 returns an HTTP status code 404 (“no such key”) error.

  • If you don’t have the `s3:ListBucket` permission, Amazon S3 returns an HTTP status code 403 (“access denied”) error.

The following action is related to `HeadObject`:

  • GetObject][5

^

[1]: docs.aws.amazon.com/AmazonS3/latest/dev/ServerSideEncryptionCustomerKeys.html [2]: docs.aws.amazon.com/AmazonS3/latest/API/RESTCommonRequestHeaders.html [3]: tools.ietf.org/html/rfc7232 [4]: docs.aws.amazon.com/AmazonS3/latest/dev/using-with-s3-actions.html [5]: docs.aws.amazon.com/AmazonS3/latest/API/API_GetObject.html

The following waiters are defined for this operation (see #wait_until for detailed usage):

* object_exists
* object_not_exists

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,
  expected_bucket_owner: "AccountId",
})

Response structure


resp.delete_marker #=> Boolean
resp.accept_ranges #=> String
resp.expiration #=> String
resp.restore #=> String
resp.archive_status #=> String, one of "ARCHIVE_ACCESS", "DEEP_ARCHIVE_ACCESS"
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.bucket_key_enabled #=> Boolean
resp.storage_class #=> String, one of "STANDARD", "REDUCED_REDUNDANCY", "STANDARD_IA", "ONEZONE_IA", "INTELLIGENT_TIERING", "GLACIER", "DEEP_ARCHIVE", "OUTPOSTS"
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)

    The name of the bucket containing the object.

    When using this action with an access point, you must direct requests to the access point hostname. The access point hostname takes the form AccessPointName-AccountId.s3-accesspoint.Region.amazonaws.com. When using this action with an access point through the Amazon Web Services SDKs, you provide the access point ARN in place of the bucket name. For more information about access point ARNs, see [Using access points] in the *Amazon S3 User Guide*.

    When using this action with Amazon S3 on Outposts, you must direct requests to the S3 on Outposts hostname. The S3 on Outposts hostname takes the form AccessPointName-AccountId.outpostID.s3-outposts.Region.amazonaws.com. When using this action using S3 on Outposts through the Amazon Web Services SDKs, you provide the Outposts bucket ARN in place of the bucket name. For more information about S3 on Outposts ARNs, see

    Using S3 on Outposts][2

    in the *Amazon S3 User Guide*.

    [1]: docs.aws.amazon.com/AmazonS3/latest/userguide/using-access-points.html [2]: docs.aws.amazon.com/AmazonS3/latest/userguide/S3onOutposts.html

  • :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)

    The object key.

  • :range (String)

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

    <note markdown=“1”> Amazon S3 doesn't support retrieving multiple ranges of data per `GET` request.

    </note>
    

    [1]: 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 (for example, 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 S3 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 that the encryption key was transmitted without error.

  • :request_payer (String)

    Confirms that the requester knows that they will be charged for the request. Bucket owners need not specify this parameter in their requests. For information about downloading objects from requester pays buckets, see [Downloading Objects in Requestor Pays Buckets] in the *Amazon S3 User Guide*.

    [1]: 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.

  • :expected_bucket_owner (String)

    The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP `403 (Access Denied)` error.

Returns:

See Also:


6678
6679
6680
6681
# File 'lib/aws-sdk-s3/client.rb', line 6678

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. You can have up to 1,000 analytics configurations per bucket.

This action supports list pagination and does not return more than 100 configurations at a time. You should always check the `IsTruncated` element in the response. If there are no more configurations to list, `IsTruncated` is set to false. If there are more configurations to list, `IsTruncated` is set to true, and there will be a value in `NextContinuationToken`. You use the `NextContinuationToken` value to continue the pagination of the list by passing the value in continuation-token in the request to `GET` the next page.

To use this operation, you must have permissions to perform the `s3:GetAnalyticsConfiguration` action. The bucket owner has this permission by default. The bucket owner can grant this permission to others. For more information about permissions, see [Permissions Related to Bucket Subresource Operations] and [Managing Access Permissions to Your Amazon S3 Resources].

For information about Amazon S3 analytics feature, see [Amazon S3 Analytics – Storage Class Analysis].

The following operations are related to `ListBucketAnalyticsConfigurations`:

  • GetBucketAnalyticsConfiguration][4
  • DeleteBucketAnalyticsConfiguration][5
  • PutBucketAnalyticsConfiguration][6

[1]: docs.aws.amazon.com/AmazonS3/latest/userguide/using-with-s3-actions.html#using-with-s3-actions-related-to-bucket-subresources [2]: docs.aws.amazon.com/AmazonS3/latest/userguide/s3-access-control.html [3]: docs.aws.amazon.com/AmazonS3/latest/dev/analytics-storage-class.html [4]: docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketAnalyticsConfiguration.html [5]: docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteBucketAnalyticsConfiguration.html [6]: docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketAnalyticsConfiguration.html

Examples:

Request syntax with placeholder values


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

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.

  • :expected_bucket_owner (String)

    The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP `403 (Access Denied)` error.

Returns:

See Also:


6775
6776
6777
6778
# File 'lib/aws-sdk-s3/client.rb', line 6775

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

#list_bucket_intelligent_tiering_configurations(params = {}) ⇒ Types::ListBucketIntelligentTieringConfigurationsOutput

Lists the S3 Intelligent-Tiering configuration from the specified bucket.

The S3 Intelligent-Tiering storage class is designed to optimize storage costs by automatically moving data to the most cost-effective storage access tier, without performance impact or operational overhead. S3 Intelligent-Tiering delivers automatic cost savings in two low latency and high throughput access tiers. For data that can be accessed asynchronously, you can choose to activate automatic archiving capabilities within the S3 Intelligent-Tiering storage class.

The S3 Intelligent-Tiering storage class is the ideal storage class for data with unknown, changing, or unpredictable access patterns, independent of object size or retention period. If the size of an object is less than 128 KB, it is not eligible for auto-tiering. Smaller objects can be stored, but they are always charged at the Frequent Access tier rates in the S3 Intelligent-Tiering storage class.

For more information, see [Storage class for automatically optimizing frequently and infrequently accessed objects].

Operations related to `ListBucketIntelligentTieringConfigurations` include:

  • DeleteBucketIntelligentTieringConfiguration][2
  • PutBucketIntelligentTieringConfiguration][3
  • GetBucketIntelligentTieringConfiguration][4

[1]: docs.aws.amazon.com/AmazonS3/latest/dev/storage-class-intro.html#sc-dynamic-data-access [2]: docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteBucketIntelligentTieringConfiguration.html [3]: docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketIntelligentTieringConfiguration.html [4]: docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketIntelligentTieringConfiguration.html

Examples:

Request syntax with placeholder values


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

Response structure


resp.is_truncated #=> Boolean
resp.continuation_token #=> String
resp.next_continuation_token #=> String
resp.intelligent_tiering_configuration_list #=> Array
resp.intelligent_tiering_configuration_list[0].id #=> String
resp.intelligent_tiering_configuration_list[0].filter.prefix #=> String
resp.intelligent_tiering_configuration_list[0].filter.tag.key #=> String
resp.intelligent_tiering_configuration_list[0].filter.tag.value #=> String
resp.intelligent_tiering_configuration_list[0].filter.and.prefix #=> String
resp.intelligent_tiering_configuration_list[0].filter.and.tags #=> Array
resp.intelligent_tiering_configuration_list[0].filter.and.tags[0].key #=> String
resp.intelligent_tiering_configuration_list[0].filter.and.tags[0].value #=> String
resp.intelligent_tiering_configuration_list[0].status #=> String, one of "Enabled", "Disabled"
resp.intelligent_tiering_configuration_list[0].tierings #=> Array
resp.intelligent_tiering_configuration_list[0].tierings[0].days #=> Integer
resp.intelligent_tiering_configuration_list[0].tierings[0].access_tier #=> String, one of "ARCHIVE_ACCESS", "DEEP_ARCHIVE_ACCESS"

Parameters:

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

    ({})

Options Hash (params):

  • :bucket (required, String)

    The name of the Amazon S3 bucket whose configuration you want to modify or retrieve.

  • :continuation_token (String)

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

Returns:

See Also:


6864
6865
6866
6867
# File 'lib/aws-sdk-s3/client.rb', line 6864

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

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

Returns a list of inventory configurations for the bucket. You can have up to 1,000 analytics configurations per bucket.

This action supports list pagination and does not return more than 100 configurations at a time. Always check the `IsTruncated` element in the response. If there are no more configurations to list, `IsTruncated` is set to false. If there are more configurations to list, `IsTruncated` is set to true, and there is a value in `NextContinuationToken`. You use the `NextContinuationToken` value to continue the pagination of the list by passing the value in continuation-token in the request to `GET` the next page.

To use this operation, you must have permissions to perform the `s3:GetInventoryConfiguration` action. The bucket owner has this permission by default. The bucket owner can grant this permission to others. For more information about permissions, see [Permissions Related to Bucket Subresource Operations] and [Managing Access Permissions to Your Amazon S3 Resources].

For information about the Amazon S3 inventory feature, see [Amazon S3 Inventory]

The following operations are related to `ListBucketInventoryConfigurations`:

  • GetBucketInventoryConfiguration][4
  • DeleteBucketInventoryConfiguration][5
  • PutBucketInventoryConfiguration][6

[1]: docs.aws.amazon.com/AmazonS3/latest/userguide/using-with-s3-actions.html#using-with-s3-actions-related-to-bucket-subresources [2]: docs.aws.amazon.com/AmazonS3/latest/userguide/s3-access-control.html [3]: docs.aws.amazon.com/AmazonS3/latest/dev/storage-inventory.html [4]: docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketInventoryConfiguration.html [5]: docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteBucketInventoryConfiguration.html [6]: docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketInventoryConfiguration.html

Examples:

Request syntax with placeholder values


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

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", "IntelligentTieringAccessTier", "BucketKeyStatus"
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.

  • :expected_bucket_owner (String)

    The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP `403 (Access Denied)` error.

Returns:

See Also:


6962
6963
6964
6965
# File 'lib/aws-sdk-s3/client.rb', line 6962

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. The metrics configurations are only for the request metrics of the bucket and do not provide information on daily storage metrics. You can have up to 1,000 configurations per bucket.

This action supports list pagination and does not return more than 100 configurations at a time. Always check the `IsTruncated` element in the response. If there are no more configurations to list, `IsTruncated` is set to false. If there are more configurations to list, `IsTruncated` is set to true, and there is a value in `NextContinuationToken`. You use the `NextContinuationToken` value to continue the pagination of the list by passing the value in `continuation-token` in the request to `GET` the next page.

To use this operation, you must have permissions to perform the `s3:GetMetricsConfiguration` action. The bucket owner has this permission by default. The bucket owner can grant this permission to others. For more information about permissions, see [Permissions Related to Bucket Subresource Operations] and [Managing Access Permissions to Your Amazon S3 Resources].

For more information about metrics configurations and CloudWatch request metrics, see [Monitoring Metrics with Amazon CloudWatch].

The following operations are related to `ListBucketMetricsConfigurations`:

  • PutBucketMetricsConfiguration][4
  • GetBucketMetricsConfiguration][5
  • DeleteBucketMetricsConfiguration][6

[1]: docs.aws.amazon.com/AmazonS3/latest/userguide/using-with-s3-actions.html#using-with-s3-actions-related-to-bucket-subresources [2]: docs.aws.amazon.com/AmazonS3/latest/userguide/s3-access-control.html [3]: docs.aws.amazon.com/AmazonS3/latest/dev/cloudwatch-monitoring.html [4]: docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketMetricsConfiguration.html [5]: docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketMetricsConfiguration.html [6]: docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteBucketMetricsConfiguration.html

Examples:

Request syntax with placeholder values


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

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.access_point_arn #=> 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
resp.metrics_configuration_list[0].filter.and.access_point_arn #=> 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.

  • :expected_bucket_owner (String)

    The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP `403 (Access Denied)` error.

Returns:

See Also:


7060
7061
7062
7063
# File 'lib/aws-sdk-s3/client.rb', line 7060

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:


7117
7118
7119
7120
# File 'lib/aws-sdk-s3/client.rb', line 7117

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

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

This action lists in-progress multipart uploads. An in-progress multipart upload is a multipart upload that has been initiated using the Initiate Multipart Upload request, but has not yet been completed or aborted.

This action returns at most 1,000 multipart uploads in the response. 1,000 multipart uploads is the maximum number of uploads a response can include, which is also the default value. You can further limit the number of uploads in a response by specifying the `max-uploads` parameter in the response. If additional multipart uploads satisfy the list criteria, the response will contain an `IsTruncated` element with the value true. To list the additional multipart uploads, use the `key-marker` and `upload-id-marker` request parameters.

In the response, the uploads are sorted by key. If your application has initiated more than one multipart upload using the same object key, then uploads in the response are first sorted by key. Additionally, uploads are sorted in ascending order within each key by the upload initiation time.

For more information on multipart uploads, see [Uploading Objects Using Multipart Upload].

For information on permissions required to use the multipart upload API, see [Multipart Upload and Permissions].

The following operations are related to `ListMultipartUploads`:

  • CreateMultipartUpload][3
  • UploadPart][4
  • CompleteMultipartUpload][5
  • ListParts][6
  • AbortMultipartUpload][7

[1]: docs.aws.amazon.com/AmazonS3/latest/dev/uploadobjusingmpu.html [2]: docs.aws.amazon.com/AmazonS3/latest/dev/mpuAndPermissions.html [3]: docs.aws.amazon.com/AmazonS3/latest/API/API_CreateMultipartUpload.html [4]: docs.aws.amazon.com/AmazonS3/latest/API/API_UploadPart.html [5]: docs.aws.amazon.com/AmazonS3/latest/API/API_CompleteMultipartUpload.html [6]: docs.aws.amazon.com/AmazonS3/latest/API/API_ListParts.html [7]: docs.aws.amazon.com/AmazonS3/latest/API/API_AbortMultipartUpload.html

The returned response is a pageable response and is Enumerable. For details on usage see PageableResponse.

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",
  expected_bucket_owner: "AccountId",
})

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", "DEEP_ARCHIVE", "OUTPOSTS"
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)

    The name of the bucket to which the multipart upload was initiated.

    When using this action with an access point, you must direct requests to the access point hostname. The access point hostname takes the form AccessPointName-AccountId.s3-accesspoint.Region.amazonaws.com. When using this action with an access point through the Amazon Web Services SDKs, you provide the access point ARN in place of the bucket name. For more information about access point ARNs, see [Using access points] in the *Amazon S3 User Guide*.

    When using this action with Amazon S3 on Outposts, you must direct requests to the S3 on Outposts hostname. The S3 on Outposts hostname takes the form AccessPointName-AccountId.outpostID.s3-outposts.Region.amazonaws.com. When using this action using S3 on Outposts through the Amazon Web Services SDKs, you provide the Outposts bucket ARN in place of the bucket name. For more information about S3 on Outposts ARNs, see

    Using S3 on Outposts][2

    in the *Amazon S3 User Guide*.

    [1]: docs.aws.amazon.com/AmazonS3/latest/userguide/using-access-points.html [2]: docs.aws.amazon.com/AmazonS3/latest/userguide/S3onOutposts.html

  • :delimiter (String)

    Character you use to group keys.

    All keys that contain the same string between the prefix, if specified, and the first occurrence of the delimiter after the prefix are grouped under a single result element, `CommonPrefixes`. If you don't specify the prefix parameter, then the substring starts at the beginning of the key. The keys that are grouped under `CommonPrefixes` result element are not returned elsewhere in the response.

  • :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.

    If `upload-id-marker` is not specified, only the keys lexicographically greater than the specified `key-marker` will be included in the list.

    If `upload-id-marker` is specified, any multipart uploads for a key equal to the `key-marker` might also be included, provided those multipart uploads have upload IDs lexicographically greater than the specified `upload-id-marker`.

  • :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. You can use prefixes to separate a bucket into different grouping of keys. (You can think of using prefix to make groups in the same way you'd use a folder in a file system.)

  • :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. Otherwise, any multipart uploads for a key equal to the key-marker might be included in the list only if they have an upload ID lexicographically greater than the specified `upload-id-marker`.

  • :expected_bucket_owner (String)

    The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP `403 (Access Denied)` error.

Returns:

See Also:


7404
7405
7406
7407
# File 'lib/aws-sdk-s3/client.rb', line 7404

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 versions of the objects in a bucket. You can also use request parameters as selection criteria to return metadata about a subset of all the object versions.

To use this operation, you must have permissions to perform the `s3:ListBucketVersions` action. Be aware of the name difference.

<note markdown=“1”> A 200 OK response can contain valid or invalid XML. Make sure to design your application to parse the contents of the response and handle it appropriately.

</note>

To use this operation, you must have READ access to the bucket.

This action is not supported by Amazon S3 on Outposts.

The following operations are related to `ListObjectVersions`:

  • ListObjectsV2][1
  • GetObject][2
  • PutObject][3
  • DeleteObject][4

[1]: docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjectsV2.html [2]: docs.aws.amazon.com/AmazonS3/latest/API/API_GetObject.html [3]: docs.aws.amazon.com/AmazonS3/latest/API/API_PutObject.html [4]: docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteObject.html

The returned response is a pageable response and is Enumerable. For details on usage see PageableResponse.

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",
  expected_bucket_owner: "AccountId",
})

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)

    The bucket name that contains the objects.

  • :delimiter (String)

    A delimiter is a character that you specify to group keys. All keys that contain the same string between the `prefix` and the first occurrence of the delimiter are grouped under a single result element in CommonPrefixes. These groups are counted as one result against the max-keys limitation. These keys are not returned elsewhere in the response.

  • :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. By default the action returns up to 1,000 key names. The response might contain fewer keys but will never contain more. If additional keys satisfy the search criteria, but were not returned because max-keys was exceeded, the response contains &lt;isTruncated&gt;true&lt;/isTruncated&gt;. To return the additional keys, see key-marker and version-id-marker.

  • :prefix (String)

    Use this parameter to select only those keys that begin with the specified prefix. You can use prefixes to separate a bucket into different groupings of keys. (You can think of using prefix to make groups in the same way you'd use a folder in a file system.) You can use prefix with delimiter to roll up numerous objects into a single result under CommonPrefixes.

  • :version_id_marker (String)

    Specifies the object version you want to start listing from.

  • :expected_bucket_owner (String)

    The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP `403 (Access Denied)` error.

Returns:

See Also:


7600
7601
7602
7603
# File 'lib/aws-sdk-s3/client.rb', line 7600

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 1,000) 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. A 200 OK response can contain valid or invalid XML. Be sure to design your application to parse the contents of the response and handle it appropriately.

This action has been revised. We recommend that you use the newer version, [ListObjectsV2], when developing applications. For backward compatibility, Amazon S3 continues to support `ListObjects`.

The following operations are related to `ListObjects`:

  • ListObjectsV2][1
  • GetObject][2
  • PutObject][3
  • CreateBucket][4
  • ListBuckets][5

[1]: docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjectsV2.html [2]: docs.aws.amazon.com/AmazonS3/latest/API/API_GetObject.html [3]: docs.aws.amazon.com/AmazonS3/latest/API/API_PutObject.html [4]: docs.aws.amazon.com/AmazonS3/latest/API/API_CreateBucket.html [5]: docs.aws.amazon.com/AmazonS3/latest/API/API_ListBuckets.html

The returned response is a pageable response and is Enumerable. For details on usage see PageableResponse.

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
  expected_bucket_owner: "AccountId",
})

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", "DEEP_ARCHIVE", "OUTPOSTS"
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)

    The name of the bucket containing the objects.

    When using this action with an access point, you must direct requests to the access point hostname. The access point hostname takes the form AccessPointName-AccountId.s3-accesspoint.Region.amazonaws.com. When using this action with an access point through the Amazon Web Services SDKs, you provide the access point ARN in place of the bucket name. For more information about access point ARNs, see [Using access points] in the *Amazon S3 User Guide*.

    When using this action with Amazon S3 on Outposts, you must direct requests to the S3 on Outposts hostname. The S3 on Outposts hostname takes the form AccessPointName-AccountId.outpostID.s3-outposts.Region.amazonaws.com. When using this action using S3 on Outposts through the Amazon Web Services SDKs, you provide the Outposts bucket ARN in place of the bucket name. For more information about S3 on Outposts ARNs, see

    Using S3 on Outposts][2

    in the *Amazon S3 User Guide*.

    [1]: docs.aws.amazon.com/AmazonS3/latest/userguide/using-access-points.html [2]: docs.aws.amazon.com/AmazonS3/latest/userguide/S3onOutposts.html

  • :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)

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

  • :max_keys (Integer)

    Sets the maximum number of keys returned in the response. By default the action returns up to 1,000 key names. 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.

  • :expected_bucket_owner (String)

    The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP `403 (Access Denied)` error.

Returns:

See Also:


7786
7787
7788
7789
# File 'lib/aws-sdk-s3/client.rb', line 7786

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 1,000) of the objects in a bucket with each request. You can use the request parameters as selection criteria to return a subset of the objects in a bucket. A `200 OK` response can contain valid or invalid XML. Make sure to design your application to parse the contents of the response and handle it appropriately. Objects are returned sorted in an ascending order of the respective key names in the list. For more information about listing objects, see

Listing object keys programmatically][1

To use this operation, you must have READ access to the bucket.

To use this action in an Identity and Access Management (IAM) policy, you must have permissions to perform the `s3:ListBucket` action. The bucket owner has this permission by default and can grant this permission to others. For more information about permissions, see

Permissions Related to Bucket Subresource Operations][2

and

[Managing Access Permissions to Your Amazon S3 Resources].

This section describes the latest revision of this action. We recommend that you use this revised API for application development. For backward compatibility, Amazon S3 continues to support the prior version of this API, [ListObjects].

To get a list of your buckets, see [ListBuckets].

The following operations are related to `ListObjectsV2`:

  • GetObject][6
  • PutObject][7
  • CreateBucket][8

[1]: docs.aws.amazon.com/AmazonS3/latest/userguide/ListingKeysUsingAPIs.html [2]: docs.aws.amazon.com/AmazonS3/latest/userguide/using-with-s3-actions.html#using-with-s3-actions-related-to-bucket-subresources [3]: docs.aws.amazon.com/AmazonS3/latest/userguide/s3-access-control.html [4]: docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjects.html [5]: docs.aws.amazon.com/AmazonS3/latest/API/API_ListBuckets.html [6]: docs.aws.amazon.com/AmazonS3/latest/API/API_GetObject.html [7]: docs.aws.amazon.com/AmazonS3/latest/API/API_PutObject.html [8]: docs.aws.amazon.com/AmazonS3/latest/API/API_CreateBucket.html

The returned response is a pageable response and is Enumerable. For details on usage see PageableResponse.

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
  expected_bucket_owner: "AccountId",
})

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", "DEEP_ARCHIVE", "OUTPOSTS"
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)

    Bucket name to list.

    When using this action with an access point, you must direct requests to the access point hostname. The access point hostname takes the form AccessPointName-AccountId.s3-accesspoint.Region.amazonaws.com. When using this action with an access point through the Amazon Web Services SDKs, you provide the access point ARN in place of the bucket name. For more information about access point ARNs, see [Using access points] in the *Amazon S3 User Guide*.

    When using this action with Amazon S3 on Outposts, you must direct requests to the S3 on Outposts hostname. The S3 on Outposts hostname takes the form AccessPointName-AccountId.outpostID.s3-outposts.Region.amazonaws.com. When using this action using S3 on Outposts through the Amazon Web Services SDKs, you provide the Outposts bucket ARN in place of the bucket name. For more information about S3 on Outposts ARNs, see

    Using S3 on Outposts][2

    in the *Amazon S3 User Guide*.

    [1]: docs.aws.amazon.com/AmazonS3/latest/userguide/using-access-points.html [2]: docs.aws.amazon.com/AmazonS3/latest/userguide/S3onOutposts.html

  • :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. By default the action returns up to 1,000 key names. 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.

  • :expected_bucket_owner (String)

    The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP `403 (Access Denied)` error.

Returns:

See Also:


7995
7996
7997
7998
# File 'lib/aws-sdk-s3/client.rb', line 7995

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. This operation must include the upload ID, which you obtain by sending the initiate multipart upload request (see [CreateMultipartUpload]). This request returns a maximum of 1,000 uploaded parts. The default number of parts returned is 1,000 parts. You can restrict the number of parts returned by specifying the `max-parts` request parameter. If your multipart upload consists of more than 1,000 parts, the response returns an `IsTruncated` field with the value of true, and a `NextPartNumberMarker` element. In subsequent `ListParts` requests you can include the part-number-marker query string parameter and set its value to the `NextPartNumberMarker` field value from the previous response.

For more information on multipart uploads, see [Uploading Objects Using Multipart Upload].

For information on permissions required to use the multipart upload API, see [Multipart Upload and Permissions].

The following operations are related to `ListParts`:

  • CreateMultipartUpload][1
  • UploadPart][4
  • CompleteMultipartUpload][5
  • AbortMultipartUpload][6
  • ListMultipartUploads][7

[1]: docs.aws.amazon.com/AmazonS3/latest/API/API_CreateMultipartUpload.html [2]: docs.aws.amazon.com/AmazonS3/latest/dev/uploadobjusingmpu.html [3]: docs.aws.amazon.com/AmazonS3/latest/dev/mpuAndPermissions.html [4]: docs.aws.amazon.com/AmazonS3/latest/API/API_UploadPart.html [5]: docs.aws.amazon.com/AmazonS3/latest/API/API_CompleteMultipartUpload.html [6]: docs.aws.amazon.com/AmazonS3/latest/API/API_AbortMultipartUpload.html [7]: docs.aws.amazon.com/AmazonS3/latest/API/API_ListMultipartUploads.html

The returned response is a pageable response and is Enumerable. For details on usage see PageableResponse.

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
  expected_bucket_owner: "AccountId",
})

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", "DEEP_ARCHIVE", "OUTPOSTS"
resp.request_charged #=> String, one of "requester"

Parameters:

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

    ({})

Options Hash (params):

  • :bucket (required, String)

    The name of the bucket to which the parts are being uploaded.

    When using this action with an access point, you must direct requests to the access point hostname. The access point hostname takes the form AccessPointName-AccountId.s3-accesspoint.Region.amazonaws.com. When using this action with an access point through the Amazon Web Services SDKs, you provide the access point ARN in place of the bucket name. For more information about access point ARNs, see [Using access points] in the *Amazon S3 User Guide*.

    When using this action with Amazon S3 on Outposts, you must direct requests to the S3 on Outposts hostname. The S3 on Outposts hostname takes the form AccessPointName-AccountId.outpostID.s3-outposts.Region.amazonaws.com. When using this action using S3 on Outposts through the Amazon Web Services SDKs, you provide the Outposts bucket ARN in place of the bucket name. For more information about S3 on Outposts ARNs, see

    Using S3 on Outposts][2

    in the *Amazon S3 User Guide*.

    [1]: docs.aws.amazon.com/AmazonS3/latest/userguide/using-access-points.html [2]: docs.aws.amazon.com/AmazonS3/latest/userguide/S3onOutposts.html

  • :key (required, String)

    Object key for which the multipart upload was initiated.

  • :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 they will be charged for the request. Bucket owners need not specify this parameter in their requests. For information about downloading objects from requester pays buckets, see [Downloading Objects in Requestor Pays Buckets] in the *Amazon S3 User Guide*.

    [1]: docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html

  • :expected_bucket_owner (String)

    The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP `403 (Access Denied)` error.

Returns:

See Also:


8192
8193
8194
8195
# File 'lib/aws-sdk-s3/client.rb', line 8192

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. Amazon S3 Transfer Acceleration is a bucket-level feature that enables you to perform faster data transfers to Amazon S3.

To use this operation, you must have permission to perform the s3:PutAccelerateConfiguration action. The bucket owner has this permission by default. The bucket owner can grant this permission to others. For more information about permissions, see [Permissions Related to Bucket Subresource Operations] and [Managing Access Permissions to Your Amazon S3 Resources].

The Transfer Acceleration state of a bucket can be set to one of the following two values:

  • Enabled – Enables accelerated data transfers to the bucket.

  • Suspended – Disables accelerated data transfers to the bucket.

The [GetBucketAccelerateConfiguration] action returns the transfer acceleration state of a bucket.

After setting the Transfer Acceleration state of a bucket to Enabled, it might take up to thirty minutes before the data transfer rates to the bucket increase.

The name of the bucket used for Transfer Acceleration must be DNS-compliant and must not contain periods (“.”).

For more information about transfer acceleration, see [Transfer Acceleration].

The following operations are related to `PutBucketAccelerateConfiguration`:

  • GetBucketAccelerateConfiguration][3
  • CreateBucket][5

[1]: docs.aws.amazon.com/AmazonS3/latest/userguide/using-with-s3-actions.html#using-with-s3-actions-related-to-bucket-subresources [2]: docs.aws.amazon.com/AmazonS3/latest/userguide/s3-access-control.html [3]: docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketAccelerateConfiguration.html [4]: docs.aws.amazon.com/AmazonS3/latest/dev/transfer-acceleration.html [5]: docs.aws.amazon.com/AmazonS3/latest/API/API_CreateBucket.html

Examples:

Request syntax with placeholder values


resp = client.put_bucket_accelerate_configuration({
  bucket: