Created
April 12, 2014 01:10
-
-
Save lporras/10513138 to your computer and use it in GitHub Desktop.
guardar imagen
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
dirname = File.dirname(self.image_tmp) | |
path = Rails.root.join "tmp/uploads", dirname | |
file_with_path = Rails.root.join "tmp/uploads", self.image_tmp | |
FileUtils.mkdir_p(path) | |
File.open(file_with_path, "wb") { |f| f.write(open(URI.parse(url)).read) } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment