Created
February 10, 2012 22:02
-
-
Save mhayes/1793341 to your computer and use it in GitHub Desktop.
Move existing assets over to amazon s3
This file contains hidden or 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
# Assuming you've setup Dragonfly to use your local filesystem, here's what you would | |
# do to get the images over to Amazon S3 | |
# Specify the base path to where images reside on your system | |
DRAGONFLY_PATH = Rails.root.join("public", "system", "dragonfly", Rails.env) | |
# Next you'll need to loop over each model that is using dragonfly | |
SlideRiff.all.each do |riff| | |
slide_image_file = DRAGONFLY_PATH.join(riff.slide_image_uid) | |
# check if the file exists on the local filesystem, this allows you to | |
# run this if new images get added to s3 during the transition phase | |
if File.exists?(slide_image_file) | |
# grab the actual image file | |
file = File.open(slide_image_file) | |
# tell dragonfly to re-save the image which places the file onto s3 | |
riff.slide_image = file | |
riff.save | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment