1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
fog--fog/lib/fog/aws/requests/s3/put_object.rb

41 lines
1.6 KiB
Ruby
Raw Normal View History

module Fog
module AWS
class S3
# Create an object in an S3 bucket
2009-07-20 22:47:48 -04:00
#
# ==== Parameters
# * bucket_name<~String> - Name of bucket to create object in
# * object_name<~String> - Name of object to create
# * object<~String> - File to create object from
2009-07-28 01:53:51 -04:00
# * options<~Hash>:
2009-07-29 22:50:51 -04:00
# * 'Cache-Control'<~String> - Caching behaviour
# * 'Content-Disposition'<~String> - Presentational information for the object
# * 'Content-Encoding'<~String> - Encoding of object data
# * 'Content-Length'<~String> - Size of object in bytes (defaults to object.read.length)
# * 'Content-MD5'<~String> - Base64 encoded 128-bit MD5 digest of message (defaults to Base64 encoded MD5 of object.read)
# * 'Content-Type'<~String> - Standard MIME type describing contents (defaults to MIME::Types.of.first)
# * 'x-amz-acl'<~String> - Permissions, must be in ['private', 'public-read', 'public-read-write', 'authenticated-read']
# * "x-amz-meta-#{name}" - Headers to be returned with object, note total size of request without body must be less than 8 KB.
2009-07-20 22:47:48 -04:00
#
# ==== Returns
# * response<~Fog::AWS::Response>:
2009-07-29 22:50:51 -04:00
# * headers<~Hash>:
# * 'ETag'<~String> - etag of new object
def put_object(bucket_name, object_name, object, options = {})
file = parse_file(object)
2009-07-29 22:50:51 -04:00
headers = file[:headers].merge!(options)
request({
:body => file[:body],
:expects => 200,
2009-07-28 01:53:51 -04:00
:headers => headers,
:host => "#{bucket_name}.#{@host}",
:method => 'PUT',
:path => object_name
})
end
end
end
end