Class: Aliyun::Oss::Client

Inherits:
Object
  • Object
show all
Includes:
Api::BucketMultiparts, Api::BucketObjects, Api::BucketProperty, Api::Buckets
Defined in:
lib/aliyun/oss/client/clients.rb,
lib/aliyun/oss/client.rb,
lib/aliyun/oss/client/buckets.rb,
lib/aliyun/oss/client/bucket_objects.rb,
lib/aliyun/oss/client/bucket_multiparts.rb

Overview

Here is some services used to make object based API possible, they are all contains a reference to instance of client, which used to do the real job.

buckets: used to do many buckets operations eg: #list, #create, #delete

client.buckets

bucket_objects: used to do some operation on objects eg: #list, #create, :delete, #copy

client.bucket_objects

bucket_multiparts: used to do some operation for multiparts eg: #init, #list

client.bucket_multiparts

current_bucket: get current bucket

client.current_bucket

Defined Under Namespace

Modules: BucketMultiparts, BucketObjects, Buckets Classes: BucketMultipartsService, BucketObjectsService, BucketsService, ClientService

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Api::BucketMultiparts

#bucket_abort_multipart, #bucket_complete_multipart, #bucket_init_multipart, #bucket_list_multiparts, #bucket_list_parts, #bucket_multipart_copy_upload, #bucket_multipart_upload

Methods included from Api::BucketObjects

#bucket_append_object, #bucket_copy_object, #bucket_create_object, #bucket_delete_object, #bucket_delete_objects, #bucket_get_meta_object, #bucket_get_object, #bucket_get_object_acl, #bucket_get_object_share_link, #bucket_list_objects, #bucket_set_object_acl

Methods included from Api::BucketProperty

#bucket_disable_cors, #bucket_disable_lifecycle, #bucket_disable_logging, #bucket_disable_website, #bucket_enable_cors, #bucket_enable_lifecycle, #bucket_enable_logging, #bucket_enable_website, #bucket_get_acl, #bucket_get_cors, #bucket_get_lifecycle, #bucket_get_location, #bucket_get_logging, #bucket_get_referer, #bucket_get_website, #bucket_set_acl, #bucket_set_referer

Methods included from Api::Buckets

#bucket_create, #bucket_delete, #bucket_preflight, #list_buckets

Constructor Details

#initialize(access_key, secret_key, options = {}) ⇒ Response

Initialize a object

Examples:

Aliyun::Oss::Client.new("ACCESS_KEY", "SECRET_KEY", host: "oss-cn-beijing.aliyuncs.com", bucket: 'oss-sdk-beijing')

Parameters:

  • access_key (String)

    access_key obtained from aliyun

  • secret_key (String)

    secret_key obtained from aliyun

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

    a customizable set of options

Options Hash (options):

  • :host (String)

    host for bucket’s data center

  • :bucket (String)

    Bucket name



33
34
35
36
37
38
39
40
# File 'lib/aliyun/oss/client.rb', line 33

def initialize(access_key, secret_key, options = {})
  @access_key = access_key
  @secret_key = secret_key
  @options = options
  @bucket = options[:bucket]

  @services = {}
end

Instance Attribute Details

#access_keyObject (readonly)

Returns the value of attribute access_key.



20
21
22
# File 'lib/aliyun/oss/client.rb', line 20

def access_key
  @access_key
end

#bucketObject (readonly)

Returns the value of attribute bucket.



20
21
22
# File 'lib/aliyun/oss/client.rb', line 20

def bucket
  @bucket
end

#secret_keyObject (readonly)

Returns the value of attribute secret_key.



20
21
22
# File 'lib/aliyun/oss/client.rb', line 20

def secret_key
  @secret_key
end

Instance Method Details

#bucket_multipartsObject



32
33
34
35
# File 'lib/aliyun/oss/client/clients.rb', line 32

def bucket_multiparts
  @services[:bucket_multiparts] ||= \
    Client::BucketMultipartsService.new(self)
end

#bucket_objectsObject



28
29
30
# File 'lib/aliyun/oss/client/clients.rb', line 28

def bucket_objects
  @services[:bucket_objects] ||= Client::BucketObjectsService.new(self)
end

#bucketsObject



24
25
26
# File 'lib/aliyun/oss/client/clients.rb', line 24

def buckets
  @services[:buckets] ||= Client::BucketsService.new(self)
end

#current_bucketObject



37
38
39
40
# File 'lib/aliyun/oss/client/clients.rb', line 37

def current_bucket
  @services[:current_bucket] ||= \
    Aliyun::Oss::Struct::Bucket.new(name: bucket, client: self)
end