Sha256: c212bcc0c9f9ab88593930d697ab4b379cfe9ba0c1c341b61636f6d367599476
Contents?: true
Size: 885 Bytes
Versions: 2
Compression:
Stored size: 885 Bytes
Contents
require 'mime/types' module FcrepoAdmin class DatastreamsController < ApplicationController include FcrepoAdmin::ControllerBehavior TEXT_MIME_TYPES = ['application/xml', 'application/rdf+xml', 'application/json'] before_filter :load_and_authz_object def index # @object loaded and authz'd by before_filter end def show @datastream = @object.datastreams[params[:id]] @inline = @datastream.mimeType.start_with?('text/') || TEXT_MIME_TYPES.include?(@datastream.mimeType) end def download @datastream = @object.datastreams[params[:id]] mimetypes = MIME::Types[@datastream.mimeType] send_data @datastream.content, :disposition => 'attachment', :type => @datastream.mimeType, :filename => "#{@datastream.pid.sub(/:/, '_')}_#{@datastream.dsid}.#{mimetypes.first.extensions.first}" end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
fcrepo_admin-0.1.1 | app/controllers/fcrepo_admin/datastreams_controller.rb |
fcrepo_admin-0.1.0 | app/controllers/fcrepo_admin/datastreams_controller.rb |