Permalink
Browse files

Added block call support to s3_interface.

  • Loading branch information...
1 parent 73edb5c commit 0fe68e67f5d364a2d76cf5424785247a7106324d @sergeyenin sergeyenin committed with konstantin-dzreev May 29, 2012
Showing with 6 additions and 6 deletions.
  1. +4 −4 lib/s3/right_s3.rb
  2. +2 −2 lib/s3/right_s3_interface.rb
View
@@ -283,9 +283,9 @@ def key(key_name, head=false, &blck)
#
# bucket.put('logs/today/1.log', 'Olala!') #=> true
#
- def put(key, data=nil, meta_headers={}, perms=nil, headers={})
+ def put(key, data=nil, meta_headers={}, perms=nil, headers={}, &blck)
key = Key.create(self, key.to_s, data, meta_headers) unless key.is_a?(Key)
- key.put(data, perms, headers)
+ key.put(data, perms, headers, &blck)
end
# Retrieve data object from Amazon.
@@ -519,11 +519,11 @@ def get(headers={})
# ...
# key.put('Olala!') #=> true
#
- def put(data=nil, perms=nil, headers={})
+ def put(data=nil, perms=nil, headers={}, &blck)
headers['x-amz-acl'] = perms if perms
@data = data || @data
meta = self.class.add_meta_prefix(@meta_headers)
- @bucket.s3.interface.put(@bucket.name, @name, @data, meta.merge(headers))
+ @bucket.s3.interface.put(@bucket.name, @name, @data, meta.merge(headers), &blck)
end
# Store object data on S3 using the Multipart Upload API. This is useful if you do not know the file size
@@ -435,7 +435,7 @@ def under_max_keys(internal_options)
# mode.
#
- def put(bucket, key, data=nil, headers={})
+ def put(bucket, key, data=nil, headers={}, &blck)
# On Windows, if someone opens a file in text mode, we must reset it so
# to binary mode for streaming to work properly
if(data.respond_to?(:binmode))
@@ -446,7 +446,7 @@ def put(bucket, key, data=nil, headers={})
headers['expect'] = '100-continue'
end
req_hash = generate_rest_request('PUT', headers.merge(:url=>"#{bucket}/#{CGI::escape key}", :data=>data))
- request_info(req_hash, RightHttp2xxParser.new)
+ request_info(req_hash, RightHttp2xxParser.new, &blck)
rescue
on_exception
end

0 comments on commit 0fe68e6

Please sign in to comment.