Sha256: b0d0cd8688c0f65e4d79295da998ecffb1ed02f9a044804aba1aa3912a3c7211

Contents?: true

Size: 1.46 KB

Versions: 6

Compression:

Stored size: 1.46 KB

Contents

require 'mediashelf/active_fedora_helper'
class GetController < ApplicationController
    include MediaShelf::ActiveFedoraHelper
    include Hydra::RepositoryController
    helper :downloads
    
    def show
      fedora_object = ActiveFedora::Base.load_instance(params[:id])
      
      respond_to do |format|
        format.html { send_datastream downloadables( fedora_object, :canonical=>true ) }
        format.pdf { send_datastream downloadables( fedora_object, :canonical=>true, :mime_type=>"application/pdf" ) }
        format.jp2 do 
          canonical_jp2 = downloadables( fedora_object, :canonical=>true, :mime_type=>"image/jp2" )
          jp2_content_url = "#{canonical_jp2.url}/content"
          if params["image_server"]
            if params["image_server"]["scale"] 
              send_data Djatoka.scale(jp2_content_url, params["image_server"]["scale"]), :type=>"image/jpeg"
            elsif   params["image_server"]["region"] 
              send_data Djatoka.region(jp2_content_url, params["image_server"]["region"]), :type=>"image/jpeg"
            else
              send_data Djatoka.get_image(jp2_content_url, params["image_server"]["region"]), :type=>"image/jpeg"
            end
          else
            send_datastream canonical_jp2
          end
        end
      end
      
    end
    
    private
    def send_datastream(datastream)
      send_data datastream.content, :filename=>datastream.label, :type=>datastream.attributes["mimeType"]
    end
    
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
hydra-head-3.1.0.rc1 app/controllers/get_controller.rb
hydra-head-3.1.0.pre5 app/controllers/get_controller.rb
hydra-head-3.1.0.pre4 app/controllers/get_controller.rb
hydra-head-3.1.0.pre3 app/controllers/get_controller.rb
hydra-head-3.1.0.pre2 app/controllers/get_controller.rb
hydra-head-3.1.0.pre1 app/controllers/get_controller.rb