Created
December 12, 2014 19:19
-
-
Save mchail/3ad3d9eda2843ae8ca67 to your computer and use it in GitHub Desktop.
recover ad images
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a = Ad.find "53c354433486db904c000010" | |
s = a.site | |
ads = [] | |
s.ads.each{|a| begin; open a.image.url; rescue; ads << a; end} | |
def move(a) | |
source_key = Paperclip::Interpolations.interpolate "ads/:attachment/:id_partition/:style/:filename", a.image, :original | |
target_key = Paperclip::Interpolations.interpolate "images/:hash/:style.:extension", a.image, :original | |
m = MigrateAds.new | |
moved = m.instance_variable_get(:@s3).buckets[m.instance_variable_get(:@bucket_name)].objects[source_key].copy_to(target_key, :acl => :public_read) | |
end | |
load 'script/tools/migrate_ads.rb' | |
ads.each{|a| move a} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment