Feature Requests: Browse | Submit New | Admin

[#27711] Updating metadata without re-uploading the file

Date:
2010-01-20 22:50
Priority:
3
Submitted By:
John Drummond (drummondj)
Assigned To:
Nobody (None)
Category:
None
State:
Open
Summary:
Updating metadata without re-uploading the file

Detailed description
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.

Add A Comment: Notepad

Please login


Followup

No Followups Have Been Posted

Attached Files:

Name Description Download
No Files Currently Attached

Changes:

No Changes Have Been Made to This Item