# 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 @video.save, you run @video.encode! | |
def swfupload | |
@video = Video.new(params[: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.save && @video.encode!(test) | |
render :json => {:message => "Video was successfully uploaded. Encoding has commenced automatically."} | |
else | |
render :json => {:errors => @video.errors.full_messages.to_sentence.capitalize} | |
end | |
end | |
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 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment