Module: Aliyun::Oss::Api::Buckets
- Included in:
- Client
- Defined in:
- lib/aliyun/oss/api/buckets.rb
Instance Method Summary collapse
-
#bucket_create(name, location = 'oss-cn-hangzhou', acl = 'private') ⇒ Response
Create bucket.
-
#bucket_delete(name) ⇒ Response
Delete bucket.
-
#bucket_preflight(object_key, origin, request_method, request_headers = []) ⇒ Response
OPTIONS Object.
-
#list_buckets(options = {}) ⇒ Response
List buckets.
Instance Method Details
#bucket_create(name, location = 'oss-cn-hangzhou', acl = 'private') ⇒ Response
Create bucket
39 40 41 42 43 44 45 46 |
# File 'lib/aliyun/oss/api/buckets.rb', line 39 def bucket_create(name, location = 'oss-cn-hangzhou', acl = 'private') query = { 'acl' => true } headers = { 'x-oss-acl' => acl } body = XmlGenerator.generate_create_bucket_xml(location) http.put('/', query: query, headers: headers, body: body, bucket: name, location: location) end |
#bucket_delete(name) ⇒ Response
Delete bucket
57 58 59 |
# File 'lib/aliyun/oss/api/buckets.rb', line 57 def bucket_delete(name) http.delete('/', bucket: name) end |
#bucket_preflight(object_key, origin, request_method, request_headers = []) ⇒ Response
OPTIONS Object
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/aliyun/oss/api/buckets.rb', line 73 def bucket_preflight(object_key, origin, request_method, request_headers = []) path = object_key ? "/#{object_key}" : '/' headers = { 'Origin' => origin, 'Access-Control-Request-Method' => request_method } unless request_headers.empty? value = request_headers.join(',') headers.merge!('Access-Control-Request-Headers' => value) end http.(path, headers: headers, bucket: bucket, key: object_key) end |
#list_buckets(options = {}) ⇒ Response
List buckets
17 18 19 20 21 |
# File 'lib/aliyun/oss/api/buckets.rb', line 17 def list_buckets( = {}) Utils.stringify_keys!() query = Utils.hash_slice(, 'prefix', 'marker', 'max-keys') http.get('/', query: query) end |