Created
November 1, 2016 04:57
-
-
Save Uysim/7496cf94bc565bbcded363d6c4e384a7 to your computer and use it in GitHub Desktop.
this gist code use for move your carrirerwave file from assets s3 of amazon to you local file.
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
CarrierWave.configure do |config| | |
config.storage = :fog | |
config.fog_credentials = { | |
provider: 'AWS', | |
aws_access_key_id: ENV['AWS_ACCESS_KEY_ID'], | |
aws_secret_access_key: ENV['AWS_SECRET_ACCESS_KEY'], | |
region: ENV['FOG_REGION'] | |
} | |
config.fog_directory = ENV['S3_BUCKET_NAME'] | |
end | |
images = {} | |
Image.all.each do |image| | |
images[image.id.to_s]=image.file.url | |
end | |
CarrierWave.configure do |config| | |
config.storage = :file | |
end | |
Image.all.each do |image| | |
image.remote_file_url=images[image.id.to_s] | |
image.save | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment