Class: CBin::OSS::Helper
- Inherits:
-
Object
- Object
- CBin::OSS::Helper
- Defined in:
- lib/cocoapods-lhj-bin/helpers/oss_helper.rb
Class Method Summary collapse
Instance Method Summary collapse
- #delete(key) ⇒ Object
- #down_load(key, file, &block) ⇒ Object
-
#initialize ⇒ Helper
constructor
A new instance of Helper.
- #list ⇒ Object
- #object_url(key) ⇒ Object
- #upload(key, file) ⇒ Object
- #url_path ⇒ Object
Constructor Details
#initialize ⇒ Helper
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
.instance ⇒ Object
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 |
#list ⇒ Object
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 |