lib/s3/right_s3_interface.rb
# Saves object to Amazon. Returns +true+  or an exception.
# Any header starting with AMAZON_METADATA_PREFIX is considered
# user metadata. It will be stored with the object and returned
# when you retrieve the object. The total size of the HTTP
# request, not including the body, must be less than 4 KB.
#
#  s3.put('my_awesome_bucket', 'log/current/1.log', 'Ola-la!', 'x-amz-meta-family'=>'Woho556!') #=> true
#
# This method is capable of 'streaming' uploads; that is, it can upload
# data from a file or other IO object without first reading all the data
# into memory.  This is most useful for large PUTs - it is difficult to read
# a 2 GB file entirely into memory before sending it to S3.
# To stream an upload, pass an object that responds to 'read' (like the read
# method of IO) and to either 'lstat' or 'size'.  For files, this means
# streaming is enabled by simply making the call:
#
#  s3.put(bucket_name, 'S3keyname.forthisfile',  File.open('localfilename.dat'))
#
# If the IO object you wish to stream from responds to the read method but
# doesn't implement lstat or size, you can extend the object dynamically
# to implement these methods, or define your own class which defines these
# methods.  Be sure that your class returns 'nil' from read() after having
# read 'size' bytes. Otherwise S3 will drop the socket after
# 'Content-Length' bytes have been uploaded, and HttpConnection will
# interpret this as an error. 
#    
# This method now supports very large PUTs, where very large
# is > 2 GB. 
# 
# For Win32 users: Files and IO objects should be opened in binary mode.  If
# a text mode IO object is passed to PUT, it will be converted to binary
# mode.
#
Saves object to Amazon. Returns +true+  or an exception.
Any header starting with AMAZON_METADATA_PREFIX is considered
user metadata. It will be stored with the object and returned
when you retrieve the object. The total size of the HTTP
request, not including the body, must be less than 4 KB.



This method is capable of 'streaming' uploads; that is, it can upload
data from a file or other IO object without first reading all the data
into memory.  This is most useful for large PUTs - it is difficult to read
a 2 GB file entirely into memory before sending it to S3.



If the IO object you wish to stream from responds to the read method but
doesn't implement lstat or size, you can extend the object dynamically
to implement these methods, or define your own class which defines these
methods.  Be sure that your class returns 'nil' from read() after having
read 'size' bytes. Otherwise S3 will drop the socket after
'Content-Length' bytes have been uploaded, and HttpConnection will
interpret this as an error.

This method now supports very large PUTs, where very large
is > 2 GB.

For Win32 users: Files and IO objects should be opened in binary mode.  If
a text mode IO object is passed to PUT, it will be converted to binary
mode.
Saves object to Amazon . Returns + true + or an exception . Any header starting with AMAZON_METADATA_PREFIX is considered user metadata . It will be stored with the object and returned when you retrieve the object . The total size of the HTTP request not including the body must be less than 4 KB . This method is capable of ' streaming ' uploads ; that is it can upload data from a file or other IO object without first reading all the data into memory . This is most useful for large PUTs - it is difficult to read a 2 GB file entirely into memory before sending it to S3 . If the IO object you wish to stream from responds to the read method but doesn ' t implement lstat or size you can extend the object dynamically to implement these methods or define your own class which defines these methods . Be sure that your class returns ' nil ' from read () after having read ' size ' bytes . Otherwise S3 will drop the socket after ' Content - Length ' bytes have been uploaded and HttpConnection will interpret this as an error . This method now supports very large PUTs where very large is > 2 GB . For Win32 users : Files and IO objects should be opened in binary mode . If a text mode IO object is passed to PUT it will be converted to binary mode .
def put(bucket, key, data=nil, headers={}, &blck)
      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))
      request_info(req_hash, RightHttp2xxParser.new, &blck)
    rescue
      on_exception
    end
def put ( bucket , key , data = nil , headers = { } , & blck ) 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 ) ) request_info ( req_hash , RightHttp2xxParser . new , & blck ) rescue on_exception end
Saves object to Amazon.
Saves object to Amazon .
# On Windows, if someone opens a file in text mode, we must reset it so # to binary mode for streaming to work properly
bucket
<not_specific>
key
<not_specific>
data
<not_specific>
headers
<not_specific>
blck
<not_specific>