Skip to content

Instantly share code, notes, and snippets.

@iamvery
Created July 29, 2013 20:24
Show Gist options
  • Select an option

  • Save iamvery/6107481 to your computer and use it in GitHub Desktop.

Select an option

Save iamvery/6107481 to your computer and use it in GitHub Desktop.
require 'base64'
class SnapshotsController < AuthenticatedController
protect_from_forgery except: :create
def create
chart1 = snapshot.split(',')
image = Base64.decode64(chart1[1])
file = File.open("/tmp/test.png", 'wb') do|f|
f.write(image)
end
current_user.snapshot = File.open('/tmp/test.png')
current_user.save!
current_user.notify_new_snapshot
head :ok
end
private
def snapshot
params[:snapshot]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment