There's a bug in
http://github.com/appoxy/aws/blob/master/lib/s3/right_s3_interface.rb
around line 395 as of 6/3/2010. The code snippet:
def put(bucket, key, data=nil, headers={})
# 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))
data.binmode
end
if (data.respond_to?(:lstat) && data.lstat.size >=
USE_100_CONTINUE_PUT_SIZE) ||
(data.respond_to?(:size) && data.size >=
USE_100_CONTINUE_PUT_SIZE)
headers['expect'] = '100-continue'
end
req_hash = generate_rest_request('PUT',
headers.merge(:url=>"#{bucket}/#{CGI::escape key}", :data=>data,
'Content-
Length' => ((data && data.size) || 0).to_s))
request_info(req_hash, RightHttp2xxParser.new)
rescue
on_exception
end
uses two different methods for getting the size of the data - either
through lstat, or through size. Files don't have a size method (it's a
static in the class) so the addition of (data && data.size) breaks
upload of File instances.
Fixed code (read data_size only once and use it in both referenced
locations):
def put(bucket, key, data=nil, headers={})
# 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))
data.binmode
end
data_size = data.respond_to?(:lstat) ? data.lstat.size :
(data.respond_to?(:size) ? data.size : 0)
if (data_size >= USE_100_CONTINUE_PUT_SIZE)
headers['expect'] = '100-continue'
end
req_hash = generate_rest_request('PUT',
headers.merge(:url=>"#{bucket}/#{CGI::escape key}", :data=>data,
'Content-
Length' => data_size.to_s))
request_info(req_hash, RightHttp2xxParser.new)
rescue
on_exception
end
Workaround: Monkeypatch File to add a size method that calls
lstat.size.