Skip to content

Instantly share code, notes, and snippets.

@Uysim
Created November 1, 2016 04:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Uysim/7496cf94bc565bbcded363d6c4e384a7 to your computer and use it in GitHub Desktop.
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.
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