requests_controller.rb
920 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
class VLibras::RequestsController < ApplicationController
protect_from_forgery with: :null_session, :only => [ :callback ]
before_filter :check_vlibras_api_status, :only => [ :rapid, :create ]
def rapid
@request = VLibras::Request.new
end
def create
@request = VLibras::Request.build_from_params(params, current_user)
video = FileUploader.new
video.cache!(params[:video])
subtitle = FileUploader.new
subtitle.cache!(params[:subtitle])
files = { :video => video, :subtitle => subtitle }
if @request.save
@request.perform_request(files)
flash[:success] = 'Sua requisição foi submetida com sucesso!'
redirect_to v_libras_videos_path
else
flash[:error] = 'Algo deu errado com a sua requisição.'
render :action => :rapid
end
end
def callback
ApiClient::CallbackProcessor.process(params)
render :text => "OK!"
end
end