Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
# don't forget to turn off forgery protection:
# protect_from_forgery :except => [:swfupload, :encode_notify]
# if you're not using swfupload, code like this would be in your create and update methods
# all you really need to ensure is that after, you run @video.encode!
def swfupload
@video =[:video])
@video.swfupload_file = params[:Filedata]
# if we're in production, test should be nil but otherwise we're going to want to encode
# videos using Zencoder's test setting so we're not spending cash to do so
RAILS_ENV == "production" ? test = {} : test = {:test => 1}
if && @video.encode!(test)
render :json => {:message => "Video was successfully uploaded. Encoding has commenced automatically."}
render :json => {:errors => @video.errors.full_messages.to_sentence.capitalize}
def encode_notify
# get the job id so we can find the video
video = Video.find_by_job_id(params[:job][:id].to_i)
video.capture_notification(params[:output]) if video
render :text => "Thanks, Zencoder!", :status => 200
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment