fog 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/fog.gemspec +1 -1
- data/lib/fog/aws/models/s3/objects.rb +2 -2
- data/lib/fog/connection.rb +2 -2
- data/spec/aws/models/s3/objects_spec.rb +11 -0
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.8
|
data/fog.gemspec
CHANGED
@@ -24,8 +24,8 @@ module Fog
|
|
24
24
|
object
|
25
25
|
end
|
26
26
|
|
27
|
-
def get(key, options = {})
|
28
|
-
data = connection.get_object(bucket.name, key, options)
|
27
|
+
def get(key, options = {}, &block)
|
28
|
+
data = connection.get_object(bucket.name, key, options, &block)
|
29
29
|
object_data = {
|
30
30
|
:body => data.body,
|
31
31
|
:key => key
|
data/lib/fog/connection.rb
CHANGED
@@ -88,7 +88,7 @@ unless Fog.mocking?
|
|
88
88
|
|
89
89
|
unless params[:method] == 'HEAD'
|
90
90
|
if response.headers['Content-Length']
|
91
|
-
|
91
|
+
if error || !params[:block]
|
92
92
|
body << @connection.read(response.headers['Content-Length'].to_i)
|
93
93
|
else
|
94
94
|
remaining = response.headers['Content-Length'].to_i
|
@@ -102,7 +102,7 @@ unless Fog.mocking?
|
|
102
102
|
# 2 == "/r/n".length
|
103
103
|
chunk_size = @connection.readline.chomp!.to_i(16) + 2
|
104
104
|
chunk = @connection.read(chunk_size)[0...-2]
|
105
|
-
|
105
|
+
if error || !params[:block]
|
106
106
|
body << chunk
|
107
107
|
else
|
108
108
|
params[:block].call(chunk)
|
@@ -77,6 +77,17 @@ describe 'Fog::AWS::S3::Objects' do
|
|
77
77
|
object.destroy
|
78
78
|
end
|
79
79
|
|
80
|
+
it "should return chunked data if given a block" do
|
81
|
+
file = File.open(File.dirname(__FILE__) + '/../../../lorem.txt', 'r')
|
82
|
+
object = @bucket.objects.create(:key => 'fogobjectname', :body => file)
|
83
|
+
data = ''
|
84
|
+
@bucket.objects.get('fogobjectname') do |chunk|
|
85
|
+
data << chunk
|
86
|
+
end
|
87
|
+
data.should == File.open(File.dirname(__FILE__) + '/../../../lorem.txt', 'r').read
|
88
|
+
object.destroy
|
89
|
+
end
|
90
|
+
|
80
91
|
end
|
81
92
|
|
82
93
|
describe "#head" do
|