Sha256: 9070b27977c7900a1822b4bc19b601a877de2952820541485e0b669927b90e0c

Contents?: true

Size: 659 Bytes

Versions: 4

Compression:

Stored size: 659 Bytes

Contents

require 'mime/types'

module FcrepoAdmin
  class DownloadController < ApplicationController

    include Hydra::Controller::DownloadBehavior

    protected

    def load_asset
      @asset = ActiveFedora::Base.load_instance_from_solr(params[:object_id])
    end

    def datastream_to_show
      asset.datastreams[params[:id]]
    end

    # Pattern: pid__dsid.ext (replacing colon in pid with underscore)
    def datastream_name
      "#{datastream.pid.sub(/:/, '_')}__#{datastream.dsid}.#{datastream_extension}"
    end

    private

    def datastream_extension
      MIME::Types[datastream.mimeType].first.extensions.first rescue 'bin'
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
fcrepo_admin-0.6.1 app/controllers/fcrepo_admin/download_controller.rb
fcrepo_admin-0.6.0 app/controllers/fcrepo_admin/download_controller.rb
fcrepo_admin-0.5.5 app/controllers/fcrepo_admin/download_controller.rb
fcrepo_admin-0.5.5.pre app/controllers/fcrepo_admin/download_controller.rb