Module: Aliyun::Oss::Client::BucketObjects

Included in:
BucketObjectsService
Defined in:
lib/aliyun/oss/client/bucket_objects.rb

Instance Method Summary collapse

Instance Method Details

#append(*args) ⇒ HTTParty::Response::Headers

Append data to a object, will create Appendable object

Parameters:

  • key (String)

    object name

  • file (file, bin data)

    the data to append

  • position (Integer)

    append to position of object

  • headers (Hash)

    a customizable set of options

Returns:

  • (HTTParty::Response::Headers)

Raises:

See Also:



90
91
92
# File 'lib/aliyun/oss/client/bucket_objects.rb', line 90

def append(*args)
  client.bucket_append_object(*args).headers
end

#copy(*args) ⇒ true

Copy from existing object

Parameters:

  • key (String)

    the object name

  • source_bucket (String)

    the source bucket name

  • source_key (String)

    the source object name

  • headers (Hash)

Returns:

  • (true)

Raises:

See Also:



66
67
68
# File 'lib/aliyun/oss/client/bucket_objects.rb', line 66

def copy(*args)
  !!client.bucket_copy_object(*args)
end

#create(*args) ⇒ true

create object of bucket

Parameters:

  • key (String)

    Specify object name

  • file (File, Bin data)

    Specify need upload resource

  • headers (Hash)

    Specify other options

Returns:

  • (true)

See Also:



30
31
32
# File 'lib/aliyun/oss/client/bucket_objects.rb', line 30

def create(*args)
  !!client.bucket_create_object(*args)
end

#delete(*args) ⇒ true

Delete object for bucket

Parameters:

  • key (String)

    the object name

Returns:

  • (true)

See Also:



42
43
44
# File 'lib/aliyun/oss/client/bucket_objects.rb', line 42

def delete(*args)
  !!client.bucket_delete_object(*args)
end

#delete_multiple(*args) ⇒ true

Delete objects for bucket

Parameters:

  • keys (Array<String>)

    the object names

  • quiet (Boolean)

    Specify response mode: false(Quiet) return results for error objects, true(Verbose) return results of every objects

Returns:

  • (true)

See Also:



54
55
56
# File 'lib/aliyun/oss/client/bucket_objects.rb', line 54

def delete_multiple(*args)
  !!client.bucket_delete_objects(*args)
end

#get(*args) ⇒ BodyString

Get Object

Parameters:

  • key (String)

    the object name

  • query (Hash)

    query params

  • headers (Hash)

    headers

Returns:

  • (BodyString)

See Also:



78
79
80
# File 'lib/aliyun/oss/client/bucket_objects.rb', line 78

def get(*args)
  client.bucket_get_object(*args).body
end

#list(*args) ⇒ Array<Aliyun::Oss::Struct::Object>

List objects of bucket

Parameters:

  • options (Hash)

    options

Returns:

See Also:



13
14
15
16
17
18
19
20
# File 'lib/aliyun/oss/client/bucket_objects.rb', line 13

def list(*args)
  result = client.bucket_list_objects(*args).parsed_response

  object_keys = %w(ListBucketResult Contents)
  directory_keys = %w(ListBucketResult CommonPrefixes)
  Struct::Object.init_from_response(result, object_keys, client) + \
    Struct::Object.init_from_response(result, directory_keys, client)
end