Class: DownloadController

Inherits:
ApplicationController
  • Object
show all
Includes:
Blacklight::SolrHelper
Defined in:
app/controllers/download_controller.rb

Instance Method Summary collapse

Instance Method Details

#fileObject


15
16
17
18
19
20
# File 'app/controllers/download_controller.rb', line 15

def file  # Grab the solr document to check if it should be public or not

  @response, @document = get_solr_response_for_doc_id(file_name_to_id(params[:id]))
  restricted_should_authenticate
  send_file "tmp/cache/downloads/#{params[:id]}.#{params[:format]}", type: 'application/zip', x_sendfile: true
end

#hglObject


22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'app/controllers/download_controller.rb', line 22

def hgl
  @response, @document = get_solr_response_for_doc_id params[:id]
  if params[:email]
    response = HglDownload.new(@document, params[:email]).get
    if response.nil?
      flash[:danger] = t 'geoblacklight.download.error'
    else
      flash[:success] = t 'geoblacklight.download.hgl_success'
    end
    respond_to do |format|
      format.json { render json: flash, response: response }
      format.html { render json: flash, response: response }
    end
  else
    render layout: false
  end
end

#showObject


4
5
6
7
8
9
10
11
12
13
# File 'app/controllers/download_controller.rb', line 4

def show
  @response, @document = get_solr_response_for_doc_id params[:id]
  restricted_should_authenticate
  response = check_type
  validate response
  respond_to do |format|
    format.json { render json: flash, response: response }
    format.html { render json: flash, response: response }
  end
end