minio-ruby 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/minio-ruby.rb +38 -59
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 39e3fd6d2c353de451bb7d86f94ed5cf2c6fb2cd
|
4
|
+
data.tar.gz: 968bb9778ba723eceb3bf19894b49ef7fdac11db
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3dc00adba849574a028aabd947cc11fbba65933bd82dc18e688b85ed5d7a7083fe71a703f2e2502a81dfe12dab35c37ce3aa3775bb99c79c49bc9575691a1d08
|
7
|
+
data.tar.gz: 5a6b22c68d1ad526e12f300745ac85a48ed37b9800fd9c5991dd9ad410333904d9978c4ebfbb12223667ee015cc32a850c5948b266d53737669fcc81d24c177b
|
data/lib/minio-ruby.rb
CHANGED
@@ -9,96 +9,75 @@ require 'digest'
|
|
9
9
|
|
10
10
|
module MinioRuby
|
11
11
|
class MinioClient
|
12
|
-
attr_accessor :
|
12
|
+
attr_accessor :end_point, :port, :access_key, :secret_key, :secure, :transport, :region, :debug
|
13
13
|
|
14
|
-
def initialize
|
15
|
-
# TODO: add extensive error checking of params here.
|
14
|
+
def initialize(params = {})
|
15
|
+
# TODO: add extensive error checking of params here.
|
16
|
+
params[:debug] = params[:debug] ? params[:debug] : false
|
16
17
|
params.each { |key, value| send "#{key}=", value }
|
17
18
|
end
|
18
19
|
|
19
|
-
def
|
20
|
+
def get_object(bucket_name, object_name)
|
21
|
+
url = "#{end_point}/#{bucket_name}#{object_name}"
|
22
|
+
headers = sign_headers url
|
20
23
|
|
21
|
-
|
22
|
-
signer = MinioRuby::Signer.new(access_key: self.accessKey, secret_key: self.secretKey, region: self.region)
|
23
|
-
body = ""
|
24
|
-
headers = {}
|
25
|
-
headers = signer.sign_v4("GET", req, headers, body, true)
|
26
|
-
|
27
|
-
uri = URI.parse(self.endPoint)
|
24
|
+
uri = URI.parse(end_point)
|
28
25
|
https = Net::HTTP.new(uri.host, uri.port)
|
29
|
-
https.use_ssl =
|
26
|
+
https.use_ssl = secure
|
30
27
|
|
31
|
-
req = Net::HTTP::Get.new(
|
32
|
-
req.body =
|
28
|
+
req = Net::HTTP::Get.new(url, initheader = headers)
|
29
|
+
req.body = ''
|
33
30
|
https.set_debug_output($stdout)
|
34
|
-
https.request(
|
31
|
+
https.request(url)
|
35
32
|
end
|
36
33
|
|
37
34
|
|
38
|
-
def
|
39
|
-
|
40
|
-
|
41
|
-
headers = {}
|
42
|
-
headers = signer.sign_v4("PUT", req, headers, data, true)
|
35
|
+
def put_object(bucket_name, object_name, data)
|
36
|
+
url = "#{end_point}/#{bucket_name}#{object_name}"
|
37
|
+
headers = sign_headers url
|
43
38
|
|
44
39
|
puts data
|
45
|
-
uri = URI.parse(
|
40
|
+
uri = URI.parse(end_point)
|
46
41
|
https = Net::HTTP.new(uri.host, uri.port)
|
47
|
-
https.use_ssl =
|
42
|
+
https.use_ssl = secure
|
48
43
|
|
49
|
-
req = Net::HTTP::Put.new(
|
44
|
+
req = Net::HTTP::Put.new(url, initheader = headers)
|
50
45
|
req.body = data
|
51
46
|
https.set_debug_output($stdout)
|
52
|
-
|
53
|
-
|
54
|
-
end
|
55
|
-
|
56
|
-
|
57
|
-
def bucketExists(bucketname)
|
58
|
-
|
59
|
-
|
60
|
-
end
|
61
|
-
|
62
|
-
|
63
|
-
def fputObject(bucketname, objectname, filepath, content_type)
|
64
|
-
|
65
|
-
|
47
|
+
https.request(req)
|
66
48
|
end
|
67
49
|
|
68
|
-
def makeBucket(bucketname, location='us-east-1')
|
69
|
-
|
70
|
-
method = "PUT"
|
71
|
-
headers = { 'User-Agent' => 'MinioRuby' }
|
72
|
-
content = ""
|
73
|
-
signer = MinioRuby::Signer.new(access_key: self.accessKey, secret_key: self.secretKey, region: self.region)
|
74
|
-
body = ""
|
75
50
|
|
76
|
-
|
77
|
-
req = self.endPoint + '/' + bucketname
|
51
|
+
def bucket_exists(bucket_name); end
|
78
52
|
|
79
53
|
|
80
|
-
|
81
|
-
#headers['Content-Md5'] = Digest::MD5.base64digest(content)
|
54
|
+
def fput_object(bucket_name, object_name, file_path, content_type); end
|
82
55
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
uri = URI.parse(self.endPoint + '/' + bucketname)
|
56
|
+
def make_bucket(bucket_name)
|
57
|
+
url = "#{end_point}/#{bucket_name}"
|
58
|
+
headers = sign_headers url
|
59
|
+
uri = URI.parse(url)
|
88
60
|
|
89
61
|
https = Net::HTTP.new(uri.host, uri.port)
|
90
|
-
https.use_ssl =
|
62
|
+
https.use_ssl = secure
|
91
63
|
|
92
64
|
req = Net::HTTP::Put.new(uri, initheader = headers)
|
93
|
-
req.body =
|
65
|
+
req.body = ''
|
94
66
|
https.set_debug_output($stdout)
|
95
|
-
response = https.request(
|
67
|
+
response = https.request(url)
|
96
68
|
|
97
|
-
if response.code !=
|
98
|
-
puts
|
69
|
+
if response.code != '200'
|
70
|
+
puts 'Error Making bucket'
|
99
71
|
else
|
100
|
-
puts
|
72
|
+
puts 'Made bucket'
|
101
73
|
end
|
102
74
|
end
|
75
|
+
|
76
|
+
private
|
77
|
+
|
78
|
+
def sign_headers(url)
|
79
|
+
signer = MinioRuby::Signer.new(access_key: access_key, secret_key: secret_key, region: region)
|
80
|
+
signer.sign_v4('PUT', url, { 'User-Agent' => 'MinioRuby' }, '',true)
|
81
|
+
end
|
103
82
|
end
|
104
83
|
end
|