fog 0.0.6 → 0.0.7
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.
- data/VERSION +1 -1
- data/fog.gemspec +2 -2
- data/lib/fog/aws/requests/s3/get_object.rb +12 -2
- data/lib/fog/aws/s3.rb +1 -1
- data/lib/fog/connection.rb +11 -4
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.7
|
data/fog.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{fog}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.7"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Wesley Beary"]
|
12
|
-
s.date = %q{2009-09-
|
12
|
+
s.date = %q{2009-09-10}
|
13
13
|
s.description = %q{brings clouds to you}
|
14
14
|
s.email = %q{me@geemus.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -54,7 +54,7 @@ else
|
|
54
54
|
module AWS
|
55
55
|
class S3
|
56
56
|
|
57
|
-
def get_object(bucket_name, object_name, options = {})
|
57
|
+
def get_object(bucket_name, object_name, options = {}, &block)
|
58
58
|
unless bucket_name
|
59
59
|
raise ArgumentError.new('bucket_name is required')
|
60
60
|
end
|
@@ -79,7 +79,17 @@ else
|
|
79
79
|
'ETag' => object['ETag'],
|
80
80
|
'Last-Modified' => object['LastModified']
|
81
81
|
}
|
82
|
-
|
82
|
+
unless block_given?
|
83
|
+
response.body = object[:body]
|
84
|
+
else
|
85
|
+
data = StringIO.new(object[:body])
|
86
|
+
remaining = data.length
|
87
|
+
while remaining > 0
|
88
|
+
chunk = data.read([remaining, Fog::Connection::CHUNK_SIZE].min)
|
89
|
+
block.call(chunk)
|
90
|
+
remaining -= Fog::Connection::CHUNK_SIZE
|
91
|
+
end
|
92
|
+
end
|
83
93
|
end
|
84
94
|
else
|
85
95
|
response.status = 404
|
data/lib/fog/aws/s3.rb
CHANGED
@@ -96,7 +96,7 @@ module Fog
|
|
96
96
|
metadata[:headers]['Content-Type'] = mime_types.first.content_type
|
97
97
|
end
|
98
98
|
metadata[:body] = data.read
|
99
|
-
metadata[:headers]['Content-Length'] = File.size(data.path)
|
99
|
+
metadata[:headers]['Content-Length'] = File.size(data.path).to_s
|
100
100
|
end
|
101
101
|
# metadata[:headers]['Content-MD5'] = Base64.encode64(Digest::MD5.digest(metadata[:body])).strip
|
102
102
|
metadata
|
data/lib/fog/connection.rb
CHANGED
@@ -11,6 +11,10 @@ unless Fog.mocking?
|
|
11
11
|
module Fog
|
12
12
|
class Connection
|
13
13
|
|
14
|
+
unless const_defined?(:CHUNK_SIZE)
|
15
|
+
CHUNK_SIZE = 1048576 # 1 megabyte
|
16
|
+
end
|
17
|
+
|
14
18
|
def initialize(url)
|
15
19
|
@uri = URI.parse(url)
|
16
20
|
@connection = TCPSocket.open(@uri.host, @uri.port)
|
@@ -49,7 +53,7 @@ unless Fog.mocking?
|
|
49
53
|
else
|
50
54
|
body = params[:body]
|
51
55
|
end
|
52
|
-
while chunk = body.read(
|
56
|
+
while chunk = body.read(CHUNK_SIZE)
|
53
57
|
@connection.write(chunk)
|
54
58
|
end
|
55
59
|
end
|
@@ -84,11 +88,14 @@ unless Fog.mocking?
|
|
84
88
|
|
85
89
|
unless params[:method] == 'HEAD'
|
86
90
|
if response.headers['Content-Length']
|
87
|
-
content = @connection.read(response.headers['Content-Length'].to_i)
|
88
91
|
unless params[:block]
|
89
|
-
body <<
|
92
|
+
body << @connection.read(response.headers['Content-Length'].to_i)
|
90
93
|
else
|
91
|
-
|
94
|
+
remaining = response.headers['Content-Length'].to_i
|
95
|
+
while remaining > 0
|
96
|
+
params[:block].call(@connection.read([CHUNK_SIZE, remaining].min))
|
97
|
+
remaining -= CHUNK_SIZE;
|
98
|
+
end
|
92
99
|
end
|
93
100
|
elsif response.headers['Transfer-Encoding'] == 'chunked'
|
94
101
|
while true
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Wesley Beary
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-09-
|
12
|
+
date: 2009-09-10 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|