bucket_client 0.1.1 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9b98f30f8dc31e8fa4a25c612e38cd7e3ac33d00ea9e3f37603be4b1d10614cc
4
- data.tar.gz: e826c3892fcfeeee404aee02bc8cda27b80c9e6236de847c567cb47a3b29328e
3
+ metadata.gz: c75f9ede2d5fdb2091d0077bf6b438a907e30db0f23af72be2c9d59ffb408d06
4
+ data.tar.gz: '07190bb3319a3939020f777a6bd2c3f57404fa3a5667047a60c81bbea8db1ac9'
5
5
  SHA512:
6
- metadata.gz: 15e6c8ea01b73fa432c265d6a02656b88e4c795623ce9399a18f6a92e35d3d50192ab72b48a3df6c8e63ea54e582b06a4417348aec7cd0206480010c225cc015
7
- data.tar.gz: c572f8e7af28528c9ccd13d8d11f71f9bc9b0c4bff908a7a143f8a3062f5fdc524c6ae4863439208e8c99a0de1ed0b4b3e87f326bc967e5a12630eadac2fc898
6
+ metadata.gz: 8dc252cad1f57768b7ba2c8b88caa29b221306b85ae137174b53f50bdd661978568b69ef835163590022456d8771c1f99c183b8e9e4c0eccd2381c00db3d7ee3
7
+ data.tar.gz: 6e22a33052f35639886d969fdc2ac21fcc89941b663d36a63d138053152021f021381a9721680f975c344d8fe6c1c3196f56b32b6634baa3130c2f1ceff2c583
data/.gitignore CHANGED
@@ -16,4 +16,6 @@
16
16
  .rspec_status
17
17
  *.gem
18
18
  .env
19
- install.sh
19
+ install.sh
20
+ Dockerfile
21
+ r.rb
@@ -103,7 +103,8 @@ module BucketClient
103
103
 
104
104
  def put_blob(payload, uri)
105
105
  mime = MimeMagic.by_magic payload
106
- resp = @http.query(:put, uri, payload, mime.type, "text/plain")
106
+ type = mime.type || "text/plain"
107
+ resp = @http.query(:put, uri, payload, type, "text/plain")
107
108
  success = resp.code === 200
108
109
  if success
109
110
  OperationResult.new(success, "Blob put", uri, resp.code)
@@ -142,7 +142,8 @@ module BucketClient
142
142
  mime = MimeMagic.by_magic payload
143
143
  data = break_uri uri
144
144
  begin
145
- @client.create_block_blob data[:bucket], data[:blob], payload, {:content_type => mime.type}
145
+ type = mime.type || "text/plain"
146
+ @client.create_block_blob data[:bucket], data[:blob], payload, {:content_type => type}
146
147
  OperationResult.new(true, "OK", uri, 204)
147
148
  rescue Azure::Core::Http::HTTPError => e
148
149
  OperationResult.new(false, e.description, nil, e.status_code)
@@ -127,7 +127,8 @@ module BucketClient
127
127
 
128
128
  def put_blob(payload, uri)
129
129
  mime = MimeMagic.by_magic payload
130
- resp = @http.query :put, uri, payload, mime.type, "application/xml"
130
+ type = mime.type || "text/plain"
131
+ resp = @http.query :put, uri, payload, type, "application/xml"
131
132
  return OperationResult.new(false, resp.content, nil, 400) unless resp.code === 200
132
133
  url = Addressable::URI.parse uri
133
134
  bucket = url.path.split("/").find {|x| !x.nil? && !x.empty?}
@@ -226,8 +227,8 @@ module BucketClient
226
227
  resp = @http.query :get, endpoint
227
228
  if resp.code === 200
228
229
  value = Ox.load(resp.content, mode: :hash)[:ListBucketResult]
229
- .select {|k| !k[:Contents].nil?}
230
- .map {|k| endpoint + k[:Contents][:Key]}
230
+ .select {|k| !k[:Contents].nil?}
231
+ .map {|k| endpoint + k[:Contents][:Key]}
231
232
  OperationResult.new(true, "OK", value, resp.code)
232
233
  else
233
234
  OperationResult.new(false, resp.content, nil, resp.code)
@@ -111,7 +111,8 @@ module BucketClient
111
111
  bucket = @client.bucket data[:bucket]
112
112
  f = StringIO.new
113
113
  f << payload
114
- file = bucket.create_file f, data[:blob], cache_control: "no-cache", content_type: mime.type
114
+ type = mime.type || "text/plain"
115
+ file = bucket.create_file f, data[:blob], cache_control: "no-cache", content_type: type
115
116
  OperationResult.new(true, "OK", file.public_url, 200)
116
117
  rescue StandardError => e
117
118
  OperationResult.new(false, e.message, nil, 400)
@@ -1,3 +1,3 @@
1
1
  module BucketClient
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bucket_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - kirinnee
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-03-10 00:00:00.000000000 Z
11
+ date: 2019-04-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: kirin_http
@@ -167,7 +167,6 @@ executables: []
167
167
  extensions: []
168
168
  extra_rdoc_files: []
169
169
  files:
170
- - ".env"
171
170
  - ".gitignore"
172
171
  - ".gitlab-ci.yml"
173
172
  - ".idea/bucket_client.iml"
@@ -176,7 +175,6 @@ files:
176
175
  - ".idea/modules.xml"
177
176
  - ".idea/runConfigurations/Integration_Test.xml"
178
177
  - ".idea/runConfigurations/Unit_Test.xml"
179
- - ".idea/vcs.xml"
180
178
  - ".rspec"
181
179
  - CODE_OF_CONDUCT.md
182
180
  - Gemfile
data/.env DELETED
@@ -1,3 +0,0 @@
1
- AWS_ID=AKIAIGBITNL6232SZRBQ
2
- AWS_SECRET=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
3
- AWS_REGION=ap-southeast-1
data/.idea/vcs.xml DELETED
@@ -1,6 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="VcsDirectoryMappings">
4
- <mapping directory="$PROJECT_DIR$" vcs="Git" />
5
- </component>
6
- </project>