swift_client 0.1.7 → 0.2.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 49eedca7f2dcfc8e50c6d43042dd3783d756e310ceb57a3a186437f4069dab1f
4
- data.tar.gz: 11e6e5fa5e5526aa27534f83fe775d223a3af101aa9a25df1101513e6f388faa
3
+ metadata.gz: e91d8e86490003310183e57091645c64e9e4b4a4462b99c82d9a804887a8e2a1
4
+ data.tar.gz: e826b43a18119d2c9057bc1ed9bcbaf774fc505d7c5313b9ec0fecdbfa1a3d55
5
5
  SHA512:
6
- metadata.gz: cc9489387e34d0f90f0e3af89dd52fe542b2af932bca75cf4144216f881d390e7856287d78c261860396c5df3fdad32d9f076a48b259a1d0c2f1e18e612093ed
7
- data.tar.gz: 5385bdf725dd8979ae20d2b4a0018a62099c5991b60b5101b1e86d693779c426491f997268379630a80f9447adec03f72168e23ff782e1c7299fd315b5b2d9d9
6
+ metadata.gz: 429ea5bbf5892ac978d33f633bd7aa5fcb2352d18c6f1d76e69af21a36ad97dc2fb7f08fc08427d39c0e08fb59a80f1591481d52723e3efcf6755ccda7ed02d4
7
+ data.tar.gz: 333a4e6328fd0b0185aca83fddfd5b07628917b2139148bdbca30ffb425e8eb8fb7600d181edc3d40ec5c0f6428dbdba48fcb6d9045ccc57175d14f64f16c862
data/README.md CHANGED
@@ -192,6 +192,16 @@ for more info.
192
192
  Takes an array containing container_name/object_name entries.
193
193
  Automatically slices and sends 1_000 items per request.
194
194
 
195
+ ## Non-chunked uploads
196
+
197
+ By default files are uploaded in chunks and using a `Transfer-Encoding:
198
+ chunked` header. You can override this by passing a `Transfer-Encoding:
199
+ identity` header:
200
+
201
+ ```ruby
202
+ put_object(object_name, data_or_io, container_name, "Transfer-Encoding" => "identity")
203
+ ```
204
+
195
205
  ## Contributing
196
206
 
197
207
  1. Fork it ( https://github.com/mrkamel/swift_client/fork )
@@ -199,3 +209,8 @@ Automatically slices and sends 1_000 items per request.
199
209
  3. Commit your changes (`git commit -am 'Add some feature'`)
200
210
  4. Push to the branch (`git push origin my-new-feature`)
201
211
  5. Create a new Pull Request
212
+
213
+ ## Semantic Versioning
214
+
215
+ Starting with version 0.2.0, SwiftClient uses Semantic Versioning:
216
+ [SemVer](http://semver.org/)
@@ -103,9 +103,12 @@ class SwiftClient
103
103
  extended_headers["Content-Type"] ||= "application/octet-stream"
104
104
  end
105
105
 
106
- extended_headers["Transfer-Encoding"] = "chunked"
107
-
108
- request :put, "/#{container_name}/#{object_name}", options.merge(:body_stream => data_or_io.respond_to?(:read) ? data_or_io : StringIO.new(data_or_io), :headers => extended_headers)
106
+ if extended_headers["Transfer-Encoding"] == "identity"
107
+ request :put, "/#{container_name}/#{object_name}", options.merge(:body => data_or_io.respond_to?(:read) ? data_or_io.read : data_or_io, :headers => extended_headers)
108
+ else
109
+ extended_headers["Transfer-Encoding"] = "chunked"
110
+ request :put, "/#{container_name}/#{object_name}", options.merge(:body_stream => data_or_io.respond_to?(:read) ? data_or_io : StringIO.new(data_or_io), :headers => extended_headers)
111
+ end
109
112
  end
110
113
 
111
114
  def post_object(object_name, container_name, headers = {}, options = {})
@@ -1,4 +1,4 @@
1
1
 
2
2
  class SwiftClient
3
- VERSION = "0.1.7"
3
+ VERSION = "0.2.0"
4
4
  end
@@ -254,6 +254,12 @@ class SwiftClientTest < MiniTest::Test
254
254
  assert_equal 201, @swift_client.put_object("object", "data", "container", "X-Object-Meta-Test" => "Test").code
255
255
  end
256
256
 
257
+ def test_put_object_nonchunked
258
+ stub_request(:put, "https://example.com/v1/AUTH_account/container/object").with(:body => "data", :headers => { "Transfer-Encoding" => "identity", "Content-Type" => "application/octet-stream", "Accept" => "application/json", "X-Auth-Token" => "Token", "X-Object-Meta-Test" => "Test" }).to_return(:status => 201, :body => "", :headers => {})
259
+
260
+ assert_equal 201, @swift_client.put_object("object", "data", "container", "X-Object-Meta-Test" => "Test", "Transfer-Encoding" => "identity").code
261
+ end
262
+
257
263
  def test_put_object_with_renewed_authorization
258
264
  stub_request(:put, "https://example.com/v1/AUTH_account/container/object").with(:body => "data", :headers => { "Transfer-Encoding" => "chunked", "Content-Type" => "application/octet-stream", "Accept" => "application/json", "X-Auth-Token" => "Token" }).to_return({ :status => 401, :body => "", :headers => {}}, { :status => 201, :body => "", :headers => {}})
259
265
 
@@ -278,6 +284,12 @@ class SwiftClientTest < MiniTest::Test
278
284
  assert_equal 201, @swift_client.put_object("object", StringIO.new("data"), "container", "X-Object-Meta-Test" => "Test").code
279
285
  end
280
286
 
287
+ def test_put_object_with_io_nonchunked
288
+ stub_request(:put, "https://example.com/v1/AUTH_account/container/object").with(:body => "data", :headers => { "Transfer-Encoding" => "identity", "Accept" => "application/json", "X-Auth-Token" => "Token", "X-Object-Meta-Test" => "Test" }).to_return(:status => 201, :body => "", :headers => {})
289
+
290
+ assert_equal 201, @swift_client.put_object("object", StringIO.new("data"), "container", "X-Object-Meta-Test" => "Test", "Transfer-Encoding" => "identity").code
291
+ end
292
+
281
293
  def test_post_object
282
294
  stub_request(:post, "https://example.com/v1/AUTH_account/container/object").with(:headers => { "Accept" => "application/json", "X-Auth-Token" => "Token", "X-Object-Meta-Test" => "Test" }).to_return(:status => 201, :body => "", :headers => {})
283
295
 
@@ -4,4 +4,4 @@ require "minitest"
4
4
  require "minitest/autorun"
5
5
  require "webmock/minitest"
6
6
  require "minitest/unit"
7
- require "mocha/mini_test"
7
+ require "mocha/minitest"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: swift_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Benjamin Vetter
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-10 00:00:00.000000000 Z
11
+ date: 2020-06-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -146,8 +146,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
146
146
  - !ruby/object:Gem::Version
147
147
  version: '0'
148
148
  requirements: []
149
- rubyforge_project:
150
- rubygems_version: 2.7.3
149
+ rubygems_version: 3.0.3
151
150
  signing_key:
152
151
  specification_version: 4
153
152
  summary: Small but powerful client to interact with OpenStack Swift