Class: CBin::OSS::Helper

Inherits:
Object
  • Object
show all
Defined in:
lib/cocoapods-lhj-bin/helpers/oss_helper.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeHelper

Returns a new instance of Helper.



7
8
9
10
11
12
# File 'lib/cocoapods-lhj-bin/helpers/oss_helper.rb', line 7

def initialize
  @client = Aliyun::OSS::Client.new(endpoint: CBin.config.oss_endpoint,
                                    access_key_id: CBin.config.oss_access_key_id,
                                    access_key_secret: CBin.config.oss_access_key_secret)
  @bucket = @client.get_bucket(CBin.config.oss_bucket)
end

Class Method Details

.instanceObject



38
39
40
# File 'lib/cocoapods-lhj-bin/helpers/oss_helper.rb', line 38

def self.instance
  @instance ||= new
end

Instance Method Details

#delete(key) ⇒ Object



34
35
36
# File 'lib/cocoapods-lhj-bin/helpers/oss_helper.rb', line 34

def delete(key)
  @bucket.delete_object(key)
end

#down_load(key, file, &block) ⇒ Object



22
23
24
# File 'lib/cocoapods-lhj-bin/helpers/oss_helper.rb', line 22

def down_load(key, file, &block)
  @bucket.get_object(key, :file => file, &block)
end

#listObject



30
31
32
# File 'lib/cocoapods-lhj-bin/helpers/oss_helper.rb', line 30

def list
  @bucket.list_objects
end

#object_url(key) ⇒ Object



26
27
28
# File 'lib/cocoapods-lhj-bin/helpers/oss_helper.rb', line 26

def object_url(key)
  @bucket.object_url(key, false)
end

#upload(key, file) ⇒ Object



18
19
20
# File 'lib/cocoapods-lhj-bin/helpers/oss_helper.rb', line 18

def upload(key, file)
  @bucket.put_object(key, :file => file)
end

#url_pathObject



14
15
16
# File 'lib/cocoapods-lhj-bin/helpers/oss_helper.rb', line 14

def url_path
  "http://#{CBin.config.oss_bucket}.#{CBin.config.oss_endpoint}"
end