Skip to content

Commit

Permalink
Revert "Support for S3::Object#stream"
Browse files Browse the repository at this point in the history
This reverts commit 4688da0.
  • Loading branch information
qoobaa committed Oct 31, 2013
1 parent 7d71bb1 commit 387585f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 31 deletions.
18 changes: 4 additions & 14 deletions lib/s3/object.rb
Expand Up @@ -89,12 +89,6 @@ def content(reload = false)
@content
end

# Streams the content of the object without caching it, providing
# successive chunks to the block
def stream(options = {}, &block)
get_object(options, &block)
end

# Saves the object, returns true if successfull.
def save
put_object
Expand Down Expand Up @@ -186,9 +180,9 @@ def copy_object(options = {})
object
end

def get_object(options = {}, &block)
def get_object(options = {})
response = object_request(:get, options)
parse_headers(response, &block)
parse_headers(response)
end

def object_headers(options = {})
Expand Down Expand Up @@ -251,7 +245,7 @@ def dump_headers
headers
end

def parse_headers(response, &block)
def parse_headers(response)
@metadata = response.to_hash.select { |k, v| k.to_s.start_with?("x-amz-meta") }
self.etag = response["etag"] if response.key?("etag")
self.content_type = response["content-type"] if response.key?("content-type")
Expand All @@ -263,11 +257,7 @@ def parse_headers(response, &block)
self.size = response["content-range"].sub(/[^\/]+\//, "").to_i
else
self.size = response["content-length"]
if block.nil?
self.content = response.body
else
response.read_body(nil, &block)
end
self.content = response.body
end
end
end
Expand Down
16 changes: 0 additions & 16 deletions test/object_test.rb
Expand Up @@ -15,7 +15,6 @@ def setup
@object_mac.content = "test2"

@response_binary = Net::HTTPOK.new("1.1", "200", "OK")
@response_binary.stubs(:read_body).multiple_yields(*%w{t e s t})
@response_binary.stubs(:body).returns("test".respond_to?(:force_encoding) ? "test".force_encoding(Encoding::BINARY) : "test")
@response_binary["etag"] = ""
@response_binary["content-type"] = "image/png"
Expand Down Expand Up @@ -134,21 +133,6 @@ def setup
assert @object_lena.content(true)
end

test "streaming" do
@object_lena.expects(:object_request).with(:get, {}).returns(@response_binary)

expected = /test/n
io = StringIO.new
@object_lena.stream do |chunk|
io.write(chunk)
end
io.seek(0)
actual = io.read
assert_match expected, actual
assert_equal "image/png", @object_lena.content_type
assert_equal @object.instance_variable_defined?(:@content), false
end

test "retrieve" do
@object_lena.expects(:object_request).with(:head, {}).returns(@response_binary)
assert @object_lena.retrieve
Expand Down
1 change: 0 additions & 1 deletion test/test_helper.rb
@@ -1,4 +1,3 @@
require "test/unit"
require "stringio"
require "mocha"
require "s3"

0 comments on commit 387585f

Please sign in to comment.