Class: DownloadController

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

Instance Method Summary collapse

Instance Method Details

#fileObject



33
34
35
36
37
38
# File 'app/controllers/download_controller.rb', line 33

def file
  # Grab the solr document to check if it should be public or not
  @response, @document = search_service.fetch(file_name_to_id(params[:id]))
  restricted_should_authenticate
  send_file download_file_path_and_name, x_sendfile: true
end

#hglObject



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'app/controllers/download_controller.rb', line 40

def hgl
  @response, @document = search_service.fetch params[:id]
  if params[:email]
    response = Geoblacklight::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



22
23
24
25
26
27
28
29
30
31
# File 'app/controllers/download_controller.rb', line 22

def show
  @response, @document = search_service.fetch 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