Sha256: c38aad17738853e78603450e69f2335bb2548e01effac95d2ef14b22a901efbc

Contents?: true

Size: 1.47 KB

Versions: 8

Compression:

Stored size: 1.47 KB

Contents

require 'mediashelf/active_fedora_helper'
class DownloadsController < ApplicationController
    include MediaShelf::ActiveFedoraHelper
    include Hydra::RepositoryController
    include Hydra::AssetsControllerHelper
    helper :downloads
    
    # Note: Actual downloads are handled by the index method insead of the show method
    # in order to avoid ActionController being clever with the filenames/extensions/formats.
    # To download a datastream, pass the datastream id as ?document_id=#{dsid} in the url
    def index
      fedora_object = ActiveFedora::Base.load_instance(params[:asset_id])
      if params[:download_id]
        @datastream = fedora_object.datastreams[params[:download_id]]
        send_datastream @datastream
        #send_data( Fedora::Repository.instance.fetch_custom(params[:document_id], "datastreams/#{datastream_id}/content") )
      else
        @datastreams = downloadables( fedora_object )
      end
    end
    
    # def show
    #   puts "params: #{params.inspect}"
    #   puts "Request: #{request.inspect}"
    #   puts "Path: #{request.path}"
    #   
    #   datastream_id = File.basename(request.path)
    #   respond_to do |format|
    #     format.html { send_data( Fedora::Repository.instance.fetch_custom(params[:document_id], "datastreams/#{datastream_id}/content") ) }
    #     format.pdf { send_data( Fedora::Repository.instance.fetch_custom(params[:document_id], "datastreams/#{datastream_id}/content") ) }
    #   end
    #   
    # end        
    
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
hydra-head-3.3.0 app/controllers/downloads_controller.rb
hydra-head-3.2.2 app/controllers/downloads_controller.rb
hydra-head-3.2.1 app/controllers/downloads_controller.rb
hydra-head-3.2.0 app/controllers/downloads_controller.rb
hydra-head-3.2.0.pre3 app/controllers/downloads_controller.rb
hydra-head-3.2.0.pre2 app/controllers/downloads_controller.rb
hydra-head-3.2.0.pre1 app/controllers/downloads_controller.rb
hydra-head-3.1.5 app/controllers/downloads_controller.rb