Class: Aws::S3::ObjectSummary
- Inherits:
-
Object
- Object
- Aws::S3::ObjectSummary
- Extended by:
- Deprecations
- Defined in:
- lib/aws-sdk-s3/object_summary.rb,
lib/aws-sdk-s3/customizations/object_summary.rb
Defined Under Namespace
Classes: Collection
Read-Only Attributes collapse
- #bucket_name ⇒ String
- #etag ⇒ String
- #key ⇒ String
- #last_modified ⇒ Time
- #owner ⇒ Types::Owner
- #size ⇒ Integer (also: #content_length)
-
#storage_class ⇒ String
The class of storage used to store the object.
Actions collapse
- #copy_from(source, options = {}) ⇒ Types::CopyObjectOutput
- #delete(options = {}) ⇒ Types::DeleteObjectOutput
- #get(options = {}, &block) ⇒ Types::GetObjectOutput
- #initiate_multipart_upload(options = {}) ⇒ MultipartUpload
- #put(options = {}) ⇒ Types::PutObjectOutput
- #restore_object(options = {}) ⇒ Types::RestoreObjectOutput
Associations collapse
- #acl ⇒ ObjectAcl
- #bucket ⇒ Bucket
- #identifiers ⇒ Object deprecated private Deprecated.
- #multipart_upload(id) ⇒ MultipartUpload
- #object ⇒ Object
- #version(id) ⇒ ObjectVersion
Instance Method Summary collapse
- #client ⇒ Client
- #copy_to(target, options = {}) ⇒ Object
-
#data ⇒ Types::Object
Returns the data for this ObjectSummary.
-
#data_loaded? ⇒ Boolean
Returns ‘true` if this resource is loaded.
-
#download_file(destination, options = {}) ⇒ Boolean
Returns ‘true` when the file is downloaded without any errors.
-
#exists?(options = {}) ⇒ Boolean
Returns ‘true` if the ObjectSummary exists.
-
#initialize(*args) ⇒ ObjectSummary
constructor
A new instance of ObjectSummary.
- #load ⇒ Object (also: #reload) private
- #move_to(target, options = {}) ⇒ void
- #presigned_post(options = {}) ⇒ PresignedPost
- #presigned_url(http_method, params = {}) ⇒ String
- #public_url(options = {}) ⇒ String
-
#upload_file(source, options = {}) ⇒ Boolean
Returns ‘true` when the object is uploaded without any errors.
- #wait_until_exists(options = {}) ⇒ ObjectSummary
- #wait_until_not_exists(options = {}) ⇒ ObjectSummary
Constructor Details
#initialize(bucket_name, key, options = {}) ⇒ ObjectSummary #initialize(options = {}) ⇒ ObjectSummary
Returns a new instance of ObjectSummary.
21 22 23 24 25 26 27 |
# File 'lib/aws-sdk-s3/object_summary.rb', line 21 def initialize(*args) = Hash === args.last ? args.pop.dup : {} @bucket_name = extract_bucket_name(args, ) @key = extract_key(args, ) @data = .delete(:data) @client = .delete(:client) || Client.new() end |
Instance Method Details
#acl ⇒ ObjectAcl
662 663 664 665 666 667 668 |
# File 'lib/aws-sdk-s3/object_summary.rb', line 662 def acl ObjectAcl.new( bucket_name: @bucket_name, object_key: @key, client: @client ) end |
#bucket ⇒ Bucket
671 672 673 674 675 676 |
# File 'lib/aws-sdk-s3/object_summary.rb', line 671 def bucket Bucket.new( name: @bucket_name, client: @client ) end |
#bucket_name ⇒ String
32 33 34 |
# File 'lib/aws-sdk-s3/object_summary.rb', line 32 def bucket_name @bucket_name end |
#copy_from(source, options = {}) ⇒ Types::CopyObjectOutput
285 286 287 288 289 290 291 292 |
# File 'lib/aws-sdk-s3/object_summary.rb', line 285 def copy_from( = {}) = .merge( bucket: @bucket_name, key: @key ) resp = @client.copy_object() resp.data end |
#copy_to(target, options = {}) ⇒ Object
19 20 21 |
# File 'lib/aws-sdk-s3/customizations/object_summary.rb', line 19 def copy_to(target, = {}) object.copy_to(target, ) end |
#data ⇒ Types::Object
Returns the data for this Aws::S3::ObjectSummary.
85 86 87 88 |
# File 'lib/aws-sdk-s3/object_summary.rb', line 85 def data load unless @data @data end |
#data_loaded? ⇒ Boolean
93 94 95 |
# File 'lib/aws-sdk-s3/object_summary.rb', line 93 def data_loaded? !!@data end |
#delete(options = {}) ⇒ Types::DeleteObjectOutput
314 315 316 317 318 319 320 321 |
# File 'lib/aws-sdk-s3/object_summary.rb', line 314 def delete( = {}) = .merge( bucket: @bucket_name, key: @key ) resp = @client.delete_object() resp.data end |
#download_file(destination, options = {}) ⇒ Boolean
Returns ‘true` when the file is downloaded without any errors.
67 68 69 |
# File 'lib/aws-sdk-s3/customizations/object_summary.rb', line 67 def download_file(destination, = {}) object.download_file(destination, ) end |
#etag ⇒ String
47 48 49 |
# File 'lib/aws-sdk-s3/object_summary.rb', line 47 def etag data.etag end |
#exists?(options = {}) ⇒ Boolean
Returns ‘true` if the ObjectSummary exists.
100 101 102 103 104 105 106 107 108 109 |
# File 'lib/aws-sdk-s3/object_summary.rb', line 100 def exists?( = {}) begin wait_until_exists(.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
400 401 402 403 404 405 406 407 |
# File 'lib/aws-sdk-s3/object_summary.rb', line 400 def get( = {}, &block) = .merge( bucket: @bucket_name, key: @key ) resp = @client.get_object(, &block) resp.data end |
#identifiers ⇒ 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.
711 712 713 714 715 716 |
# File 'lib/aws-sdk-s3/object_summary.rb', line 711 def identifiers { bucket_name: @bucket_name, key: @key } end |
#initiate_multipart_upload(options = {}) ⇒ MultipartUpload
502 503 504 505 506 507 508 509 510 511 512 513 514 |
# File 'lib/aws-sdk-s3/object_summary.rb', line 502 def initiate_multipart_upload( = {}) = .merge( bucket: @bucket_name, key: @key ) resp = @client.create_multipart_upload() MultipartUpload.new( bucket_name: @bucket_name, object_key: @key, id: resp.data.upload_id, client: @client ) end |
#key ⇒ String
37 38 39 |
# File 'lib/aws-sdk-s3/object_summary.rb', line 37 def key @key end |
#last_modified ⇒ Time
42 43 44 |
# File 'lib/aws-sdk-s3/object_summary.rb', line 42 def last_modified data.last_modified end |
#load ⇒ Object Also known as: reload
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.
76 77 78 79 |
# File 'lib/aws-sdk-s3/object_summary.rb', line 76 def load msg = "#load is not implemented, data only available via enumeration" raise NotImplementedError, msg end |
#move_to(target, options = {}) ⇒ void
This method returns an undefined value.
27 28 29 |
# File 'lib/aws-sdk-s3/customizations/object_summary.rb', line 27 def move_to(target, = {}) object.move_to(target, ) end |
#multipart_upload(id) ⇒ MultipartUpload
680 681 682 683 684 685 686 687 |
# File 'lib/aws-sdk-s3/object_summary.rb', line 680 def multipart_upload(id) MultipartUpload.new( bucket_name: @bucket_name, object_key: @key, id: id, client: @client ) end |
#object ⇒ Object
690 691 692 693 694 695 696 |
# File 'lib/aws-sdk-s3/object_summary.rb', line 690 def object Object.new( bucket_name: @bucket_name, key: @key, client: @client ) end |
#owner ⇒ Types::Owner
63 64 65 |
# File 'lib/aws-sdk-s3/object_summary.rb', line 63 def owner data.owner end |
#presigned_post(options = {}) ⇒ PresignedPost
35 36 37 |
# File 'lib/aws-sdk-s3/customizations/object_summary.rb', line 35 def presigned_post( = {}) object.presigned_post() end |
#presigned_url(http_method, params = {}) ⇒ String
43 44 45 |
# File '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
51 52 53 |
# File 'lib/aws-sdk-s3/customizations/object_summary.rb', line 51 def public_url( = {}) object.public_url() end |
#put(options = {}) ⇒ Types::PutObjectOutput
619 620 621 622 623 624 625 626 |
# File 'lib/aws-sdk-s3/object_summary.rb', line 619 def put( = {}) = .merge( bucket: @bucket_name, key: @key ) resp = @client.put_object() resp.data end |
#restore_object(options = {}) ⇒ Types::RestoreObjectOutput
650 651 652 653 654 655 656 657 |
# File 'lib/aws-sdk-s3/object_summary.rb', line 650 def restore_object( = {}) = .merge( bucket: @bucket_name, key: @key ) resp = @client.restore_object() resp.data end |
#size ⇒ Integer Also known as: content_length
52 53 54 |
# File 'lib/aws-sdk-s3/object_summary.rb', line 52 def size data.size end |
#storage_class ⇒ String
The class of storage used to store the object.
58 59 60 |
# File '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.
59 60 61 |
# File 'lib/aws-sdk-s3/customizations/object_summary.rb', line 59 def upload_file(source, = {}) object.upload_file(source, ) end |
#version(id) ⇒ ObjectVersion
700 701 702 703 704 705 706 707 |
# File 'lib/aws-sdk-s3/object_summary.rb', line 700 def version(id) ObjectVersion.new( bucket_name: @bucket_name, object_key: @key, id: id, client: @client ) end |
#wait_until_exists(options = {}) ⇒ ObjectSummary
117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/aws-sdk-s3/object_summary.rb', line 117 def wait_until_exists( = {}) , params = () waiter = Waiters::ObjectExists.new() 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
136 137 138 139 140 141 142 143 144 145 146 147 |
# File 'lib/aws-sdk-s3/object_summary.rb', line 136 def wait_until_not_exists( = {}) , params = () waiter = Waiters::ObjectNotExists.new() 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 |