Class: Aliyun::Oss::Struct::Object

Inherits:
Base
  • Object
show all
Defined in:
lib/aliyun/oss/struct/object.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Aliyun::Oss::Struct::Base

Instance Attribute Details

#bucketObject

bucket of object placed



30
31
32
# File 'lib/aliyun/oss/struct/object.rb', line 30

def bucket
  @bucket
end

#clientObject

reference to client



33
34
35
# File 'lib/aliyun/oss/struct/object.rb', line 33

def client
  @client
end

#etagObject

etag of object



12
13
14
# File 'lib/aliyun/oss/struct/object.rb', line 12

def etag
  @etag
end

#keyObject

Key of object



6
7
8
# File 'lib/aliyun/oss/struct/object.rb', line 6

def key
  @key
end

#last_modifiedObject

last modified time of object



9
10
11
# File 'lib/aliyun/oss/struct/object.rb', line 9

def last_modified
  @last_modified
end

#locationObject

location of object



27
28
29
# File 'lib/aliyun/oss/struct/object.rb', line 27

def location
  @location
end

#ownerObject

owner of object



24
25
26
# File 'lib/aliyun/oss/struct/object.rb', line 24

def owner
  @owner
end

#sizeObject

size of object



18
19
20
# File 'lib/aliyun/oss/struct/object.rb', line 18

def size
  @size
end

#storage_classObject

storage class of object



21
22
23
# File 'lib/aliyun/oss/struct/object.rb', line 21

def storage_class
  @storage_class
end

#typeObject

type of object



15
16
17
# File 'lib/aliyun/oss/struct/object.rb', line 15

def type
  @type
end

Instance Method Details

#acl!String

Get ACL for object

Returns:

  • (String)

Raises:



40
41
42
43
44
# File 'lib/aliyun/oss/struct/object.rb', line 40

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) ⇒ Hash

Get meta information of object

Parameters:

  • headers (Hash)

    headers

Returns:

  • (Hash)

Raises:



65
66
67
# File 'lib/aliyun/oss/struct/object.rb', line 65

def meta!(*args)
  client.bucket_get_meta_object(*args.unshift(key)).headers
end

#set_acl(acl) ⇒ true

Set ACL for object

Parameters:

  • acl (String)

    access value, supported value: private, public-read, public-read-write

Returns:

  • (true)

Raises:



53
54
55
# File 'lib/aliyun/oss/struct/object.rb', line 53

def set_acl(acl)
  !!client.bucket_set_object_acl(key, acl)
end