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
38
39
40
41
42
43
44
45
46
|
# File 'app/controllers/el_vfs_client/el_finder_controller.rb', line 13
def run
params = permitted_params if Rails.version.to_f >= 5.1
params.delete(:format)
params.delete(:controller)
params.delete(:action)
c = Curl::Easy.new(url) do |curl|
curl.['User-Agent'] = request.user_agent
curl.['Accept'] = 'application/json'
curl.['CLIENT_IP'] = request.env['HTTP_CLIENT_IP']
curl.['X_FORWARDED_FOR'] = request.env['HTTP_X_FORWARDED_FOR']
curl.['REMOTE_ADDR'] = request.env['REMOTE_ADDR']
curl.multipart_form_post = true
end
if params['cmd'] == 'upload'
upload = params.delete(:upload)
parameters = params.map{ |key, value| Curl::PostField.content(key, value)}
files = upload.map{ |file| Curl::PostField.file('upload[]', file.path, file.original_filename) }
c.http_post(*parameters, *files)
elsif params['cmd'] == 'put'
parameters = params.map{ |key, value| Curl::PostField.content(key, value)}
c.http_post(*parameters)
else
c.url << "?#{params.to_query}"
c.http_get
end
respond_to do |format|
format.html { render :json => c.body_str }
format.json { render :json => c.body_str }
end
end
|