Created
May 23, 2012 15:47
Paperclip string to file
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
module Paperclip | |
#converts a string into a file for paperclip to save | |
# useage | |
# self.avatar = Paperclip::string_to_file('bob.png', 'image/png', 'BASE64 here') | |
def self.string_to_file(name, type, data) | |
image = StringIO.new(data) | |
image.class.class_eval { attr_accessor :original_filename, :content_type } | |
image.original_filename = name | |
image.content_type = type | |
return image | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment