Class: MinioRuby::MinioClient
- Inherits:
-
Object
- Object
- MinioRuby::MinioClient
- Defined in:
- lib/minio-ruby.rb
Instance Attribute Summary collapse
-
#access_key ⇒ Object
Returns the value of attribute access_key.
-
#debug ⇒ Object
Returns the value of attribute debug.
-
#end_point ⇒ Object
Returns the value of attribute end_point.
-
#port ⇒ Object
Returns the value of attribute port.
-
#region ⇒ Object
Returns the value of attribute region.
-
#secret_key ⇒ Object
Returns the value of attribute secret_key.
-
#secure ⇒ Object
Returns the value of attribute secure.
-
#transport ⇒ Object
Returns the value of attribute transport.
Instance Method Summary collapse
- #bucket_exists(bucket_name) ⇒ Object
- #fput_object(bucket_name, object_name, file_path, content_type) ⇒ Object
- #get_object(bucket_name, object_name) ⇒ Object
-
#initialize(params = {}) ⇒ MinioClient
constructor
A new instance of MinioClient.
- #make_bucket(bucket_name) ⇒ Object
- #presigned_object(bucket_name, object_name, expire_in = 24 * 60 * 60) ⇒ Object
- #put_object(bucket_name, object_name, data) ⇒ Object
Constructor Details
#initialize(params = {}) ⇒ MinioClient
Returns a new instance of MinioClient.
15 16 17 18 19 |
# File 'lib/minio-ruby.rb', line 15 def initialize(params = {}) # TODO: add extensive error checking of params here. params[:debug] = params[:debug] ? params[:debug] : false params.each { |key, value| send "#{key}=", value } end |
Instance Attribute Details
#access_key ⇒ Object
Returns the value of attribute access_key.
12 13 14 |
# File 'lib/minio-ruby.rb', line 12 def access_key @access_key end |
#debug ⇒ Object
Returns the value of attribute debug.
12 13 14 |
# File 'lib/minio-ruby.rb', line 12 def debug @debug end |
#end_point ⇒ Object
Returns the value of attribute end_point.
12 13 14 |
# File 'lib/minio-ruby.rb', line 12 def end_point @end_point end |
#port ⇒ Object
Returns the value of attribute port.
12 13 14 |
# File 'lib/minio-ruby.rb', line 12 def port @port end |
#region ⇒ Object
Returns the value of attribute region.
12 13 14 |
# File 'lib/minio-ruby.rb', line 12 def region @region end |
#secret_key ⇒ Object
Returns the value of attribute secret_key.
12 13 14 |
# File 'lib/minio-ruby.rb', line 12 def secret_key @secret_key end |
#secure ⇒ Object
Returns the value of attribute secure.
12 13 14 |
# File 'lib/minio-ruby.rb', line 12 def secure @secure end |
#transport ⇒ Object
Returns the value of attribute transport.
12 13 14 |
# File 'lib/minio-ruby.rb', line 12 def transport @transport end |
Instance Method Details
#bucket_exists(bucket_name) ⇒ Object
64 |
# File 'lib/minio-ruby.rb', line 64 def bucket_exists(bucket_name); end |
#fput_object(bucket_name, object_name, file_path, content_type) ⇒ Object
67 |
# File 'lib/minio-ruby.rb', line 67 def fput_object(bucket_name, object_name, file_path, content_type); end |
#get_object(bucket_name, object_name) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/minio-ruby.rb', line 21 def get_object(bucket_name, object_name) url = "#{end_point}/#{bucket_name}/#{object_name}" headers = sign_headers 'get', url uri = URI.parse(end_point) https = Net::HTTP.new(uri.host, uri.port) https.use_ssl = secure req = Net::HTTP::Get.new(url, headers) req.body = '' https.set_debug_output($stdout) if debug https.request(req) end |
#make_bucket(bucket_name) ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/minio-ruby.rb', line 69 def make_bucket(bucket_name) url = "#{end_point}/#{bucket_name}" headers = sign_headers 'put', url uri = URI.parse(url) https = Net::HTTP.new(uri.host, uri.port) https.use_ssl = secure req = Net::HTTP::Put.new(uri, headers) req.body = '' https.set_debug_output($stdout) if debug response = https.request(req) if response.code != '200' puts 'Error Making bucket' else puts 'Made bucket' end end |
#presigned_object(bucket_name, object_name, expire_in = 24 * 60 * 60) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/minio-ruby.rb', line 35 def presigned_object(bucket_name, object_name, expire_in = 24 * 60 * 60) url = "#{end_point}/#{bucket_name}/#{object_name}" headers = sign_headers 'get', url, '', 'expire_in' => expire_in.to_s puts headers uri = URI.parse(end_point) https = Net::HTTP.new(uri.host, uri.port) https.use_ssl = secure req = Net::HTTP::Get.new(url, headers) req.body = '' https.set_debug_output($stdout) if debug https.request(req) end |
#put_object(bucket_name, object_name, data) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/minio-ruby.rb', line 50 def put_object(bucket_name, object_name, data) url = "#{end_point}/#{bucket_name}/#{object_name}" headers = sign_headers 'put', url, data uri = URI.parse(end_point) https = Net::HTTP.new(uri.host, uri.port) https.use_ssl = secure req = Net::HTTP::Put.new(url, headers) req.body = data https.set_debug_output($stdout) if debug https.request(req) end |