You are viewing documentation for version 3 of the AWS SDK for Ruby. Version 2 documentation can be found here.

Class: Aws::S3::ObjectSummary

Inherits:
Object
  • Object
show all
Defined in:
gems/aws-sdk-s3/lib/aws-sdk-s3/customizations/object_summary.rb,
gems/aws-sdk-s3/lib/aws-sdk-s3/object_summary.rb

Defined Under Namespace

Classes: Collection

Actions collapse

Associations collapse

Read-Only Attributes collapse

Instance Method Summary collapse

Constructor Details

#initialize(bucket_name, key, options = {}) ⇒ ObjectSummary #initialize(options = {}) ⇒ ObjectSummary

Returns a new instance of ObjectSummary

Overloads:

  • #initialize(bucket_name, key, options = {}) ⇒ ObjectSummary

    Parameters:

    • bucket_name (String)
    • key (String)

    Options Hash (options):

  • #initialize(options = {}) ⇒ ObjectSummary

    Options Hash (options):

    • :bucket_name (required, String)
    • :key (required, String)
    • :client (Client)


21
22
23
24
25
26
27
# File 'gems/aws-sdk-s3/lib/aws-sdk-s3/object_summary.rb', line 21

def initialize(*args)
  options = Hash === args.last ? args.pop.dup : {}
  @bucket_name = extract_bucket_name(args, options)
  @key = extract_key(args, options)
  @data = options.delete(:data)
  @client = options.delete(:client) || Client.new(options)
end

Instance Method Details

#aclObjectAcl

Returns:



757
758
759
760
761
762
763
# File 'gems/aws-sdk-s3/lib/aws-sdk-s3/object_summary.rb', line 757

def acl
  ObjectAcl.new(
    bucket_name: @bucket_name,
    object_key: @key,
    client: @client
  )
end

#bucketBucket

Returns:



766
767
768
769
770
771
# File 'gems/aws-sdk-s3/lib/aws-sdk-s3/object_summary.rb', line 766

def bucket
  Bucket.new(
    name: @bucket_name,
    client: @client
  )
end

#bucket_nameString

Returns:

  • (String)


32
33
34
# File 'gems/aws-sdk-s3/lib/aws-sdk-s3/object_summary.rb', line 32

def bucket_name
  @bucket_name
end

#clientClient

Returns:



70
71
72
# File 'gems/aws-sdk-s3/lib/aws-sdk-s3/object_summary.rb', line 70

def client
  @client
end

#content_lengthObject



5
# File 'gems/aws-sdk-s3/lib/aws-sdk-s3/customizations/object_summary.rb', line 5

alias content_length size

#copy_from(options = {}) ⇒ Types::CopyObjectOutput

Examples:

Request syntax with placeholder values


object_summary.copy_from({
  acl: "private", # accepts private, public-read, public-read-write, authenticated-read, aws-exec-read, bucket-owner-read, bucket-owner-full-control
  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",
  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
  website_redirect_location: "WebsiteRedirectLocation",
  sse_customer_algorithm: "SSECustomerAlgorithm",
  sse_customer_key: "SSECustomerKey",
  sse_customer_key_md5: "SSECustomerKeyMD5",
  ssekms_key_id: "SSEKMSKeyId",
  copy_source_sse_customer_algorithm: "CopySourceSSECustomerAlgorithm",
  copy_source_sse_customer_key: "CopySourceSSECustomerKey",
  copy_source_sse_customer_key_md5: "CopySourceSSECustomerKeyMD5",
  request_payer: "requester", # accepts requester
  tagging: "TaggingHeader",
})

Parameters:

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

    ({})

Options Hash (options):

  • :acl (String)

    The canned ACL to apply to the object.

  • :cache_control (String)

    Specifies caching behavior along the request/reply chain.

  • :content_disposition (String)

    Specifies presentational information for the object.

  • :content_encoding (String)

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

  • :content_language (String)

    The language the content is in.

  • :content_type (String)

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

  • :copy_source (required, String)

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

  • :copy_source_if_match (String)

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

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

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

  • :copy_source_if_none_match (String)

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

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

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

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

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

  • :grant_full_control (String)

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

  • :grant_read (String)

    Allows grantee to read the object data and its metadata.

  • :grant_read_acp (String)

    Allows grantee to read the object ACL.

  • :grant_write_acp (String)

    Allows grantee to write the ACL for the applicable object.

  • :metadata (Hash<String,String>)

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

  • :metadata_directive (String)

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

  • :tagging_directive (String)

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

  • :server_side_encryption (String)

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

  • :storage_class (String)

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

  • :website_redirect_location (String)

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

  • :sse_customer_algorithm (String)

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

  • :sse_customer_key (String)

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

  • :sse_customer_key_md5 (String)

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

  • :ssekms_key_id (String)

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

  • :copy_source_sse_customer_algorithm (String)

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

  • :copy_source_sse_customer_key (String)

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

  • :copy_source_sse_customer_key_md5 (String)

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

  • :request_payer (String)

    Confirms that the requester knows that she or he will be charged for the request. Bucket owners need not specify this parameter in their requests. Documentation on downloading objects from requester pays buckets can be found at http://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

Returns:



11
12
13
# File 'gems/aws-sdk-s3/lib/aws-sdk-s3/customizations/object_summary.rb', line 11

def copy_from(source, options = {})
  object.copy_from(source, options)
end

#copy_to(target, options = {}) ⇒ Object

Parameters:

  • target (S3::Object, String, Hash)

    Where to copy the object data to. target must be one of the following:

    • Aws::S3::Object
    • Hash - with :bucket and :key
    • String - formatted like "target-bucket-name/target-key"

See Also:



19
20
21
# File 'gems/aws-sdk-s3/lib/aws-sdk-s3/customizations/object_summary.rb', line 19

def copy_to(target, options = {})
  object.copy_to(target, options)
end

#dataTypes::Object

Returns the data for this Aws::S3::ObjectSummary.

Returns:

Raises:



85
86
87
88
# File 'gems/aws-sdk-s3/lib/aws-sdk-s3/object_summary.rb', line 85

def data
  load unless @data
  @data
end

#data_loaded?Boolean

Returns true if this resource is loaded. Accessing attributes or #data on an unloaded resource will trigger a call to #load.

Returns:

  • (Boolean)

    Returns true if this resource is loaded. Accessing attributes or #data on an unloaded resource will trigger a call to #load.



93
94
95
# File 'gems/aws-sdk-s3/lib/aws-sdk-s3/object_summary.rb', line 93

def data_loaded?
  !!@data
end

#delete(options = {}) ⇒ Types::DeleteObjectOutput

Examples:

Request syntax with placeholder values


object_summary.delete({
  mfa: "MFA",
  version_id: "ObjectVersionId",
  request_payer: "requester", # accepts requester
})

Parameters:

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

    ({})

Options Hash (options):

  • :mfa (String)

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

  • :version_id (String)

    VersionId used to reference a specific version of the object.

  • :request_payer (String)

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

Returns:



409
410
411
412
413
414
415
416
# File 'gems/aws-sdk-s3/lib/aws-sdk-s3/object_summary.rb', line 409

def delete(options = {})
  options = options.merge(
    bucket: @bucket_name,
    key: @key
  )
  resp = @client.delete_object(options)
  resp.data
end

#download_file(destination, options = {}) ⇒ Boolean

Returns true when the file is downloaded without any errors.

Parameters:

  • destination (String)

    Where to download the file to

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

    a customizable set of options

Returns:

  • (Boolean)

    Returns true when the file is downloaded without any errors.

See Also:



67
68
69
# File 'gems/aws-sdk-s3/lib/aws-sdk-s3/customizations/object_summary.rb', line 67

def download_file(destination, options = {})
  object.download_file(destination, options)
end

#etagString

Returns:

  • (String)


47
48
49
# File 'gems/aws-sdk-s3/lib/aws-sdk-s3/object_summary.rb', line 47

def etag
  data[:etag]
end

#exists?(options = {}) ⇒ Boolean

Returns true if the ObjectSummary exists.

Parameters:

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

    ({})

Returns:

  • (Boolean)

    Returns true if the ObjectSummary exists.



100
101
102
103
104
105
106
107
108
109
# File 'gems/aws-sdk-s3/lib/aws-sdk-s3/object_summary.rb', line 100

def exists?(options = {})
  begin
    wait_until_exists(options.merge(max_attempts: 1))
    true
  rescue Aws::Waiters::Errors::UnexpectedError => e
    raise e.error
  rescue Aws::Waiters::Errors::WaiterFailed
    false
  end
end

#get(options = {}, &block) ⇒ Types::GetObjectOutput

Examples:

Request syntax with placeholder values


object_summary.get({
  if_match: "IfMatch",
  if_modified_since: Time.now,
  if_none_match: "IfNoneMatch",
  if_unmodified_since: Time.now,
  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,
})

Parameters:

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

    ({})

Options Hash (options):

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

  • :range (String)

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

  • :response_cache_control (String)

    Sets the Cache-Control header of the response.

  • :response_content_disposition (String)

    Sets the Content-Disposition header of the response

  • :response_content_encoding (String)

    Sets the Content-Encoding header of the response.

  • :response_content_language (String)

    Sets the Content-Language header of the response.

  • :response_content_type (String)

    Sets the Content-Type header of the response.

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

    Sets the Expires header of the response.

  • :version_id (String)

    VersionId used to reference a specific version of the object.

  • :sse_customer_algorithm (String)

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

  • :sse_customer_key (String)

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

  • :sse_customer_key_md5 (String)

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

  • :request_payer (String)

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

  • :part_number (Integer)

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

Returns:



495
496
497
498
499
500
501
502
# File 'gems/aws-sdk-s3/lib/aws-sdk-s3/object_summary.rb', line 495

def get(options = {}, &block)
  options = options.merge(
    bucket: @bucket_name,
    key: @key
  )
  resp = @client.get_object(options, &block)
  resp.data
end

#initiate_multipart_upload(options = {}) ⇒ MultipartUpload

Examples:

Request syntax with placeholder values


multipartupload = object_summary.initiate_multipart_upload({
  acl: "private", # accepts private, public-read, public-read-write, authenticated-read, aws-exec-read, bucket-owner-read, bucket-owner-full-control
  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",
  metadata: {
    "MetadataKey" => "MetadataValue",
  },
  server_side_encryption: "AES256", # accepts AES256, aws:kms
  storage_class: "STANDARD", # accepts STANDARD, REDUCED_REDUNDANCY, STANDARD_IA
  website_redirect_location: "WebsiteRedirectLocation",
  sse_customer_algorithm: "SSECustomerAlgorithm",
  sse_customer_key: "SSECustomerKey",
  sse_customer_key_md5: "SSECustomerKeyMD5",
  ssekms_key_id: "SSEKMSKeyId",
  request_payer: "requester", # accepts requester
  tagging: "TaggingHeader",
})

Parameters:

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

    ({})

Options Hash (options):

  • :acl (String)

    The canned ACL to apply to the object.

  • :cache_control (String)

    Specifies caching behavior along the request/reply chain.

  • :content_disposition (String)

    Specifies presentational information for the object.

  • :content_encoding (String)

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

  • :content_language (String)

    The language the content is in.

  • :content_type (String)

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

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

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

  • :grant_full_control (String)

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

  • :grant_read (String)

    Allows grantee to read the object data and its metadata.

  • :grant_read_acp (String)

    Allows grantee to read the object ACL.

  • :grant_write_acp (String)

    Allows grantee to write the ACL for the applicable object.

  • :metadata (Hash<String,String>)

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

  • :server_side_encryption (String)

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

  • :storage_class (String)

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

  • :website_redirect_location (String)

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

  • :sse_customer_algorithm (String)

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

  • :sse_customer_key (String)

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

  • :sse_customer_key_md5 (String)

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

  • :ssekms_key_id (String)

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

  • :request_payer (String)

    Confirms that the requester knows that she or he will be charged for the request. Bucket owners need not specify this parameter in their requests. Documentation on downloading objects from requester pays buckets can be found at http://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

Returns:



597
598
599
600
601
602
603
604
605
606
607
608
609
# File 'gems/aws-sdk-s3/lib/aws-sdk-s3/object_summary.rb', line 597

def initiate_multipart_upload(options = {})
  options = options.merge(
    bucket: @bucket_name,
    key: @key
  )
  resp = @client.create_multipart_upload(options)
  MultipartUpload.new(
    bucket_name: @bucket_name,
    object_key: @key,
    id: resp.data.upload_id,
    client: @client
  )
end

#keyString

Returns:

  • (String)


37
38
39
# File 'gems/aws-sdk-s3/lib/aws-sdk-s3/object_summary.rb', line 37

def key
  @key
end

#last_modifiedTime

Returns:

  • (Time)


42
43
44
# File 'gems/aws-sdk-s3/lib/aws-sdk-s3/object_summary.rb', line 42

def last_modified
  data[:last_modified]
end

#move_to(target, options = {}) ⇒ void

This method returns an undefined value.

Parameters:

  • target (S3::Object, String, Hash)

    Where to copy the object data to. target must be one of the following:

    • Aws::S3::Object
    • Hash - with :bucket and :key
    • String - formatted like "target-bucket-name/target-key"

See Also:



27
28
29
# File 'gems/aws-sdk-s3/lib/aws-sdk-s3/customizations/object_summary.rb', line 27

def move_to(target, options = {})
  object.move_to(target, options)
end

#multipart_upload(id) ⇒ MultipartUpload

Parameters:

  • id (String)

Returns:



775
776
777
778
779
780
781
782
# File 'gems/aws-sdk-s3/lib/aws-sdk-s3/object_summary.rb', line 775

def multipart_upload(id)
  MultipartUpload.new(
    bucket_name: @bucket_name,
    object_key: @key,
    id: id,
    client: @client
  )
end

#objectObject

Returns:



785
786
787
788
789
790
791
# File 'gems/aws-sdk-s3/lib/aws-sdk-s3/object_summary.rb', line 785

def object
  Object.new(
    bucket_name: @bucket_name,
    key: @key,
    client: @client
  )
end

#ownerTypes::Owner

Returns:



63
64
65
# File 'gems/aws-sdk-s3/lib/aws-sdk-s3/object_summary.rb', line 63

def owner
  data[:owner]
end

#presigned_post(options = {}) ⇒ PresignedPost



35
36
37
# File 'gems/aws-sdk-s3/lib/aws-sdk-s3/customizations/object_summary.rb', line 35

def presigned_post(options = {})
  object.presigned_post(options)
end

#presigned_url(http_method, params = {}) ⇒ String

Parameters:

  • http_method (Symbol)

    The HTTP method to generate a presigned URL for. Valid values are :get, :put, :head, and :delete.

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

    Additional request parameters to use when generating the pre-signed URL. See the related documentation in Client for accepted params.

    HTTP Method Client Method
    :get Client#get_object
    :put Client#put_object
    :head Client#head_object
    :delete Client#delete_object

Returns:

  • (String)

See Also:



43
44
45
# File 'gems/aws-sdk-s3/lib/aws-sdk-s3/customizations/object_summary.rb', line 43

def presigned_url(http_method, params = {})
  object.presigned_url(http_method, params)
end

#public_url(options = {}) ⇒ String

Parameters:

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

    a customizable set of options

Returns:

  • (String)

See Also:



51
52
53
# File 'gems/aws-sdk-s3/lib/aws-sdk-s3/customizations/object_summary.rb', line 51

def public_url(options = {})
  object.public_url(options)
end

#put(options = {}) ⇒ Types::PutObjectOutput

Examples:

Request syntax with placeholder values


object_summary.put({
  acl: "private", # accepts private, public-read, public-read-write, authenticated-read, aws-exec-read, bucket-owner-read, bucket-owner-full-control
  body: source_file,
  cache_control: "CacheControl",
  content_disposition: "ContentDisposition",
  content_encoding: "ContentEncoding",
  content_language: "ContentLanguage",
  content_length: 1,
  content_md5: "ContentMD5",
  content_type: "ContentType",
  expires: Time.now,
  grant_full_control: "GrantFullControl",
  grant_read: "GrantRead",
  grant_read_acp: "GrantReadACP",
  grant_write_acp: "GrantWriteACP",
  metadata: {
    "MetadataKey" => "MetadataValue",
  },
  server_side_encryption: "AES256", # accepts AES256, aws:kms
  storage_class: "STANDARD", # accepts STANDARD, REDUCED_REDUNDANCY, STANDARD_IA
  website_redirect_location: "WebsiteRedirectLocation",
  sse_customer_algorithm: "SSECustomerAlgorithm",
  sse_customer_key: "SSECustomerKey",
  sse_customer_key_md5: "SSECustomerKeyMD5",
  ssekms_key_id: "SSEKMSKeyId",
  request_payer: "requester", # accepts requester
  tagging: "TaggingHeader",
})

Parameters:

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

    ({})

Options Hash (options):

  • :acl (String)

    The canned ACL to apply to the object.

  • :body (String, IO)

    Object data.

  • :cache_control (String)

    Specifies caching behavior along the request/reply chain.

  • :content_disposition (String)

    Specifies presentational information for the object.

  • :content_encoding (String)

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

  • :content_language (String)

    The language the content is in.

  • :content_length (Integer)

    Size of the body in bytes. This parameter is useful when the size of the body cannot be determined automatically.

  • :content_md5 (String)

    The base64-encoded 128-bit MD5 digest of the part data.

  • :content_type (String)

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

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

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

  • :grant_full_control (String)

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

  • :grant_read (String)

    Allows grantee to read the object data and its metadata.

  • :grant_read_acp (String)

    Allows grantee to read the object ACL.

  • :grant_write_acp (String)

    Allows grantee to write the ACL for the applicable object.

  • :metadata (Hash<String,String>)

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

  • :server_side_encryption (String)

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

  • :storage_class (String)

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

  • :website_redirect_location (String)

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

  • :sse_customer_algorithm (String)

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

  • :sse_customer_key (String)

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

  • :sse_customer_key_md5 (String)

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

  • :ssekms_key_id (String)

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

  • :request_payer (String)

    Confirms that the requester knows that she or he will be charged for the request. Bucket owners need not specify this parameter in their requests. Documentation on downloading objects from requester pays buckets can be found at http://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

Returns:



714
715
716
717
718
719
720
721
# File 'gems/aws-sdk-s3/lib/aws-sdk-s3/object_summary.rb', line 714

def put(options = {})
  options = options.merge(
    bucket: @bucket_name,
    key: @key
  )
  resp = @client.put_object(options)
  resp.data
end

#restore_object(options = {}) ⇒ Types::RestoreObjectOutput

Examples:

Request syntax with placeholder values


object_summary.restore_object({
  version_id: "ObjectVersionId",
  restore_request: {
    days: 1, # required
    glacier_job_parameters: {
      tier: "Standard", # required, accepts Standard, Bulk, Expedited
    },
  },
  request_payer: "requester", # accepts requester
})

Parameters:

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

    ({})

Options Hash (options):

Returns:



745
746
747
748
749
750
751
752
# File 'gems/aws-sdk-s3/lib/aws-sdk-s3/object_summary.rb', line 745

def restore_object(options = {})
  options = options.merge(
    bucket: @bucket_name,
    key: @key
  )
  resp = @client.restore_object(options)
  resp.data
end

#sizeInteger

Returns:

  • (Integer)


52
53
54
# File 'gems/aws-sdk-s3/lib/aws-sdk-s3/object_summary.rb', line 52

def size
  data[:size]
end

#storage_classString

The class of storage used to store the object.

Returns:

  • (String)


58
59
60
# File 'gems/aws-sdk-s3/lib/aws-sdk-s3/object_summary.rb', line 58

def storage_class
  data[:storage_class]
end

#upload_file(source, options = {}) ⇒ Boolean

Returns true when the object is uploaded without any errors.

Parameters:

  • source (String, Pathname, File, Tempfile)

    A file or path to a file on the local file system that should be uploaded to this object. If you pass an open file object, then it is your responsibility to close the file object once the upload completes.

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

    a customizable set of options

Returns:

  • (Boolean)

    Returns true when the object is uploaded without any errors.

See Also:



59
60
61
# File 'gems/aws-sdk-s3/lib/aws-sdk-s3/customizations/object_summary.rb', line 59

def upload_file(source, options = {})
  object.upload_file(source, options)
end

#version(id) ⇒ ObjectVersion

Parameters:

  • id (String)

Returns:



795
796
797
798
799
800
801
802
# File 'gems/aws-sdk-s3/lib/aws-sdk-s3/object_summary.rb', line 795

def version(id)
  ObjectVersion.new(
    bucket_name: @bucket_name,
    object_key: @key,
    id: id,
    client: @client
  )
end

#wait_until(options = {}, &block) ⇒ Resource

Deprecated.

Use [Aws::S3::Client] #wait_until instead

Note:

The waiting operation is performed on a copy. The original resource remains unchanged

Waiter polls an API operation until a resource enters a desired state.

Basic Usage

Waiter will polls until it is successful, it fails by entering a terminal state, or until a maximum number of attempts are made.

# polls in a loop until condition is true
resource.wait_until(options) {|resource| condition}

Example

instance.wait_until(max_attempts:10, delay:5) {|instance| instance.state.name == 'running' }

Configuration

You can configure the maximum number of polling attempts, and the delay (in seconds) between each polling attempt. The waiting condition is set by passing a block to #wait_until:

# poll for ~25 seconds
resource.wait_until(max_attempts:5,delay:5) {|resource|...}

Callbacks

You can be notified before each polling attempt and before each delay. If you throw :success or :failure from these callbacks, it will terminate the waiter.

started_at = Time.now
# poll for 1 hour, instead of a number of attempts
proc = Proc.new do |attempts, response|
  throw :failure if Time.now - started_at > 3600
end

  # disable max attempts
instance.wait_until(before_wait:proc, max_attempts:nil) {...}

Handling Errors

When a waiter is successful, it returns the Resource. When a waiter fails, it raises an error.

begin
  resource.wait_until(...)
rescue Aws::Waiters::Errors::WaiterFailed
  # resource did not enter the desired state in time
end

attempts attempt in seconds invoked before each attempt invoked before each wait

Parameters:

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

    a customizable set of options

Options Hash (options):

  • :max_attempts (Integer) — default: 10

    Maximum number of

  • :delay (Integer) — default: 10

    Delay between each

  • :before_attempt (Proc) — default: nil

    Callback

  • :before_wait (Proc) — default: nil

    Callback

Returns:

  • (Resource)

    if the waiter was successful

Raises:

  • (Aws::Waiters::Errors::FailureStateError)

    Raised when the waiter terminates because the waiter has entered a state that it will not transition out of, preventing success.

    yet successful.

  • (Aws::Waiters::Errors::UnexpectedError)

    Raised when an error is encountered while polling for a resource that is not expected.

  • (NotImplementedError)

    Raised when the resource does not



227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
# File 'gems/aws-sdk-s3/lib/aws-sdk-s3/object_summary.rb', line 227

def wait_until(options = {}, &block)
  self_copy = self.dup
  attempts = 0
  options[:max_attempts] = 10 unless options.key?(:max_attempts)
  options[:delay] ||= 10
  options[:poller] = Proc.new do
    attempts += 1
    if block.call(self_copy)
      [:success, self_copy]
    else
      self_copy.reload unless attempts == options[:max_attempts]
      :retry
    end
  end
  Aws::Waiters::Waiter.new(options).wait({})
end

#wait_until_exists(options = {}) ⇒ ObjectSummary

Parameters:

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

    ({})

Options Hash (options):

  • :max_attempts (Integer) — default: 20
  • :delay (Float) — default: 5
  • :before_attempt (Proc)
  • :before_wait (Proc)

Returns:



117
118
119
120
121
122
123
124
125
126
127
128
# File 'gems/aws-sdk-s3/lib/aws-sdk-s3/object_summary.rb', line 117

def wait_until_exists(options = {})
  options, params = separate_params_and_options(options)
  waiter = Waiters::ObjectExists.new(options)
  yield_waiter_and_warn(waiter, &Proc.new) if block_given?
  waiter.wait(params.merge(bucket: @bucket_name,
    key: @key))
  ObjectSummary.new({
    bucket_name: @bucket_name,
    key: @key,
    client: @client
  })
end

#wait_until_not_exists(options = {}) ⇒ ObjectSummary

Parameters:

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

    ({})

Options Hash (options):

  • :max_attempts (Integer) — default: 20
  • :delay (Float) — default: 5
  • :before_attempt (Proc)
  • :before_wait (Proc)

Returns:



136
137
138
139
140
141
142
143
144
145
146
147
# File 'gems/aws-sdk-s3/lib/aws-sdk-s3/object_summary.rb', line 136

def wait_until_not_exists(options = {})
  options, params = separate_params_and_options(options)
  waiter = Waiters::ObjectNotExists.new(options)
  yield_waiter_and_warn(waiter, &Proc.new) if block_given?
  waiter.wait(params.merge(bucket: @bucket_name,
    key: @key))
  ObjectSummary.new({
    bucket_name: @bucket_name,
    key: @key,
    client: @client
  })
end