Nathan Colgate RSS

This is the personal blog of Nathan Colgate Clark. I work at Brand New Box. I developed a content management system for churches.

Archive

Jan
8th
Fri
permalink

How to Rename a File on S3 with right_aws and Keep Permissions

Because this took way too much time to figure out:

s3=RightAws::S3Interface.new(S3SwfUpload::S3Config.access_key_id, S3SwfUpload::S3Config.secret_access_key)
old_name = "tmp/#{self.video_file_name}"
new_name = original_video_file_path
bucket = S3SwfUpload::S3Config.bucket
(1..5).each do |try|
  begin
    acl_prop = s3.get_acl(bucket, old_name)
    s3.rename(bucket, old_name, new_name)
    s3.put_acl(bucket, new_name, acl_prop[:object])
    break
  rescue Exception => e
    self.video_log += "Problem renaming file, trying again... #{e}\n"
    sleep 1
  end
end