Created
May 15, 2012 13:03
-
-
Save AlexanderPavlenko/2701595 to your computer and use it in GitHub Desktop.
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
class Base64ImageWrapper < StringIO | |
def initialize(data, name=nil) | |
@name = name || 'image' | |
@blob = Base64.decode64(data) | |
super @blob | |
end | |
def original_filename | |
"#@name.#{content_type.split('/').last}" | |
end | |
def content_type | |
@content_type ||= Magick::Image.from_blob(@blob)[0].mime_type | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment