Skip to content

Instantly share code, notes, and snippets.

@AlexanderPavlenko
Created May 15, 2012 13:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlexanderPavlenko/2701595 to your computer and use it in GitHub Desktop.
Save AlexanderPavlenko/2701595 to your computer and use it in GitHub Desktop.
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