Skip to content

Instantly share code, notes, and snippets.

@michaeldelorenzo
Last active August 29, 2015 14:22
Show Gist options
  • Save michaeldelorenzo/f8fdd292a4e314600625 to your computer and use it in GitHub Desktop.
Save michaeldelorenzo/f8fdd292a4e314600625 to your computer and use it in GitHub Desktop.
def process_logo_data_uri
if self.logo_data_uri && !self.logo_data_uri.split(",").last.nil?
data = StringIO.new(Base64.decode64(self.logo_data_uri))
data.class_eval do
attr_accessor :content_type, :original_filename
end
data.content_type = self.logo_data_uri.match(/image\/[a-z]{3,}/i).to_s
data.original_filename = "image_name.#{data.content_type.to_s}"
self.logo = data
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment