class Rack::Test::UploadedFile
def initialize_from_file_path(path)
Create a tempfile and copy the content from the given path into the tempfile, optionally renaming if
def initialize_from_file_path(path) raise "#{path} file does not exist" unless ::File.exist?(path) @original_filename ||= ::File.basename(path) extension = ::File.extname(@original_filename) @tempfile = Tempfile.new([::File.basename(@original_filename, extension), extension]) @tempfile.set_encoding(Encoding::BINARY) FileUtils.copy_file(path, @tempfile.path) end