Class Rack::Test::UploadedFile

  1. lib/rack/test/uploaded_file.rb (view online)
Parent: Object

Methods

public class

  1. new

public instance

  1. local_path
  2. path

Attributes

content_type [RW] The content type of the “uploaded” file
original_filename [R] The filename, not including the path, of the “uploaded” file

Public class methods

new (path, content_type = "text/plain", binary = false)
[show source]
# File lib/rack/test/uploaded_file.rb, line 13
      def initialize(path, content_type = "text/plain", binary = false)
        raise "#{path} file does not exist" unless ::File.exist?(path)
        @content_type = content_type
        @original_filename = ::File.basename(path)
        @tempfile = Tempfile.new(@original_filename)
        @tempfile.set_encoding(Encoding::BINARY) if @tempfile.respond_to?(:set_encoding)
        @tempfile.binmode if binary
        FileUtils.copy_file(path, @tempfile.path)
      end

Public instance methods

local_path ()

Alias for path

path ()
[show source]
# File lib/rack/test/uploaded_file.rb, line 23
      def path
        @tempfile.path
      end