summary refs log tree commit
diff options
context:
space:
mode:
authorJames Tucker <jftucker@gmail.com>2014-07-18 12:48:47 -0700
committerJames Tucker <jftucker@gmail.com>2014-07-18 12:48:47 -0700
commit2683d278913529400d13fd32b2a85e9eaa7f272c (patch)
treea54090df022ac7fcfbe067746879488e94ea8e5a
parent1aff92c9ac533dac8cc0486443d1d88cb78ad5cc (diff)
downloadrack-2683d278913529400d13fd32b2a85e9eaa7f272c.tar.gz
Rack::Multipart::UploadedFile has file extensions
Tempfiles created for file uploads now have file extensions. This enables
certain use cases for users that are using file extensions as heuristics.

Closes #690
-rw-r--r--lib/rack/multipart/uploaded_file.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/rack/multipart/uploaded_file.rb b/lib/rack/multipart/uploaded_file.rb
index 11932b17..1b56ad75 100644
--- a/lib/rack/multipart/uploaded_file.rb
+++ b/lib/rack/multipart/uploaded_file.rb
@@ -11,7 +11,7 @@ module Rack
         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 = Tempfile.new([@original_filename, ::File.extname(path)])
         @tempfile.set_encoding(Encoding::BINARY) if @tempfile.respond_to?(:set_encoding)
         @tempfile.binmode if binary
         FileUtils.copy_file(path, @tempfile.path)
@@ -31,4 +31,4 @@ module Rack
       end
     end
   end
-end \ No newline at end of file
+end