2009-07-13 22:14:59 -04:00
|
|
|
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
|
2009-07-13 22:14:59 -04:00
|
|
|
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)
|
2009-07-13 22:14:59 -04:00
|
|
|
request({
|
|
|
|
:body => file[:body],
|
2009-07-14 19:04:39 -04:00
|
|
|
:expects => 200,
|
2009-07-28 01:53:51 -04:00
|
|
|
:headers => headers,
|
2009-07-13 22:14:59 -04:00
|
|
|
:host => "#{bucket_name}.#{@host}",
|
|
|
|
:method => 'PUT',
|
|
|
|
:path => object_name
|
|
|
|
})
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|