Skip to content

Instantly share code, notes, and snippets.

@serg2801
Last active June 30, 2016 13:46
Show Gist options
  • Save serg2801/0634d1c94dcb1a8a85072d5de9d69bde to your computer and use it in GitHub Desktop.
Save serg2801/0634d1c94dcb1a8a85072d5de9d69bde to your computer and use it in GitHub Desktop.
require 'open-uri'
def all_product
products = Product.all
products.each do |product|
id = product.id
image_path = product.image.path.split('/')
image_name = image_path[4]
save_img(image_name, id)
end
end
def save_img(image_name, id_product)
open('thumb_' + "#{image_name}", 'wb') do |file|
file << open('https://geschenkeheld-community.s3.amazonaws.com/uploads/product/image/' + "#{id_product}" + '/' + "#{image_name}").read
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment