Sha256: 3f8ec4812cc2b8dba954cdae5eb20efa5e8c797163c66475355bd7521513e432

Contents?: true

Size: 528 Bytes

Versions: 7

Compression:

Stored size: 528 Bytes

Contents

module Innate
  module Helper
    module SendFile
      # Not optimally performing but convenient way to send files by their
      # filename.
      def send_file(filename, content_type = nil)
        content_type ||= Rack::Mime.mime_type(::File.extname(filename))

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

        throw(:respond, response)
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
manveru-innate-2009.02.06 lib/innate/helper/send_file.rb
manveru-innate-2009.02.21 lib/innate/helper/send_file.rb
manveru-innate-2009.02.25 lib/innate/helper/send_file.rb
manveru-innate-2009.03.24 lib/innate/helper/send_file.rb
manveru-innate-2009.04.01 lib/innate/helper/send_file.rb
manveru-innate-2009.04.08 lib/innate/helper/send_file.rb
innate-2009.04.12 lib/innate/helper/send_file.rb