Sha256: 247c6652b3516a2ab8142788a74b7f6f1125bf0c6e3b1f28af7815e5b998e311

Contents?: true

Size: 973 Bytes

Versions: 20

Compression:

Stored size: 973 Bytes

Contents

module Innate
  module Helper
    module SendFile
      # Not optimally performing but convenient way to send files by their
      # filename.
      #
      # I think we should remove this from the default helpers and move it into
      # Ramaze, the functionality is almost never used, the naming is ambigous,
      # and it doesn't use the send_file capabilities of frontend servers.
      #
      # So for now, I'll mark it for deprecation
      def send_file(filename, content_type = nil, content_disposition = nil)
        content_type ||= Rack::Mime.mime_type(::File.extname(filename))
        content_disposition ||= File.basename(filename)

        response.body = ::File.readlines(filename, 'rb')
        response['Content-Length'] = ::File.size(filename).to_s
        response['Content-Type'] = content_type
        response['Content-Disposition'] = content_disposition
        response.status = 200

        throw(:respond, response)
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 3 rubygems

Version Path
manveru-innate-2009.04.18 lib/innate/helper/send_file.rb
manveru-innate-2009.04 lib/innate/helper/send_file.rb
manveru-innate-2009.05 lib/innate/helper/send_file.rb
manveru-innate-2009.06.12 lib/innate/helper/send_file.rb
manveru-innate-2009.06 lib/innate/helper/send_file.rb
manveru-innate-2009.07 lib/innate/helper/send_file.rb
rjspotter-innate-2009.06.29 lib/innate/helper/send_file.rb
rjspotter-innate-2009.06.30 lib/innate/helper/send_file.rb
rjspotter-innate-2009.06.31 lib/innate/helper/send_file.rb
innate-2010.07 lib/innate/helper/send_file.rb
innate-2010.06.18 lib/innate/helper/send_file.rb
innate-2010.04 lib/innate/helper/send_file.rb
innate-2010.03 lib/innate/helper/send_file.rb
innate-2010.01 lib/innate/helper/send_file.rb
innate-2009.10 lib/innate/helper/send_file.rb
innate-2009.07 lib/innate/helper/send_file.rb
innate-2009.06 lib/innate/helper/send_file.rb
innate-2009.05 lib/innate/helper/send_file.rb
innate-2009.06.12 lib/innate/helper/send_file.rb
innate-2009.04 lib/innate/helper/send_file.rb