Class: Aliyun::Oss::Struct::Object
- Defined in:
- lib/aliyun/oss/struct/object.rb
Instance Attribute Summary collapse
-
#bucket ⇒ Object
bucket of object placed.
-
#client ⇒ Object
reference to client.
-
#etag ⇒ Object
etag of object.
-
#key ⇒ Object
Key of object.
-
#last_modified ⇒ Object
last modified time of object.
-
#location ⇒ Object
location of object.
-
#owner ⇒ Object
owner of object.
-
#size ⇒ Object
size of object.
-
#storage_class ⇒ Object
storage class of object.
-
#type ⇒ Object
type of object.
Class Method Summary collapse
Instance Method Summary collapse
-
#acl! ⇒ String
Get ACL for object.
-
#meta!(*args) ⇒ HTTParty::Response::Headers
Get meta information of object.
-
#set_acl(acl) ⇒ true
Set ACL for object.
Methods inherited from Base
Constructor Details
This class inherits a constructor from Aliyun::Oss::Struct::Base
Instance Attribute Details
#bucket ⇒ Object
bucket of object placed
31 32 33 |
# File 'lib/aliyun/oss/struct/object.rb', line 31 def bucket @bucket end |
#client ⇒ Object
reference to client
34 35 36 |
# File 'lib/aliyun/oss/struct/object.rb', line 34 def client @client end |
#etag ⇒ Object
etag of object
12 13 14 |
# File 'lib/aliyun/oss/struct/object.rb', line 12 def etag @etag end |
#last_modified ⇒ Object
last modified time of object
9 10 11 |
# File 'lib/aliyun/oss/struct/object.rb', line 9 def last_modified @last_modified end |
#location ⇒ Object
location of object
28 29 30 |
# File 'lib/aliyun/oss/struct/object.rb', line 28 def location @location end |
#owner ⇒ Object
owner of object
25 26 27 |
# File 'lib/aliyun/oss/struct/object.rb', line 25 def owner @owner end |
#size ⇒ Object
size of object
19 20 21 |
# File 'lib/aliyun/oss/struct/object.rb', line 19 def size @size end |
#storage_class ⇒ Object
storage class of object
22 23 24 |
# File 'lib/aliyun/oss/struct/object.rb', line 22 def storage_class @storage_class end |
#type ⇒ Object
type of object
16 17 18 |
# File 'lib/aliyun/oss/struct/object.rb', line 16 def type @type end |
Class Method Details
.init_from_object(object, client) ⇒ Object
77 78 79 80 81 82 83 84 85 |
# File 'lib/aliyun/oss/struct/object.rb', line 77 def init_from_object(object, client) if object.key?('Key') && object['Key'].end_with?('/') Struct::Directory.new(object.merge(client: client)) elsif object.key?('Prefix') && object['Prefix'].end_with?('/') Struct::Directory.new(object.merge(client: client)) else Struct::File.new(object.merge(client: client)) end end |
Instance Method Details
#acl! ⇒ String
Get ACL for object
41 42 43 44 45 |
# File 'lib/aliyun/oss/struct/object.rb', line 41 def acl! result = client.bucket_get_object_acl(key).parsed_response acl_keys = %w(AccessControlPolicy AccessControlList Grant) Utils.dig_value(result, *acl_keys).strip end |
#meta!(*args) ⇒ HTTParty::Response::Headers
Get meta information of object
66 67 68 |
# File 'lib/aliyun/oss/struct/object.rb', line 66 def (*args) client.(*args.unshift(key)).headers end |
#set_acl(acl) ⇒ true
Set ACL for object
54 55 56 |
# File 'lib/aliyun/oss/struct/object.rb', line 54 def set_acl(acl) !!client.bucket_set_object_acl(key, acl) end |