Hi,
I needed this feature for a website I'm working on, so I extended the S3Object class with:
class S3UpdatableObject < AWS::S3::S3Object
class << self
def update_header(key, bucket = nil, headers = {}, options = {} )
bucket = bucket_name(bucket)
source_key = path!(bucket, key)
default_options = { 'x-amz-copy-source' => source_key, 'x-amz-metadata-directive' => 'REPLACE' }
target_key = path!(bucket, key)
policy = acl(key, bucket) if options[:copy_acl]
returning put(target_key, default_options.merge( headers )) do
acl(key, bucket, policy ) if options[:copy_acl]
end
end
end
end
So, you can use this to update an object's metadata like this:
headers = {
'Content-Type' => ,
'Content-Disposition' => "attachment; filename=#{filename}",
}
S3UpdatableObject.update_header( path, bucket, headers, { :copy_acl => true } )
Use it if you like.
|