Skip to content

Instantly share code, notes, and snippets.

@arikfr
Created March 16, 2011 16:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arikfr/872769 to your computer and use it in GitHub Desktop.
Save arikfr/872769 to your computer and use it in GitHub Desktop.
Asset.find_in_batches do |group|
group.each do |asset|
if asset.is_image?
current_url = asset.resource.path
new_url = asset.resource.path(:large)
if AWS::S3::S3Object.exists? current_url, S3Config['bucket_name']
begin
AWS::S3::S3Object.copy current_url, new_url, S3Config['bucket_name'], :copy_acl => :true
puts "File copied [#{current_url}] => [#{new_url}]."
rescue
puts "Copy failed"
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment