diff options
author | Joshua Peek <josh@joshpeek.com> | 2009-04-14 15:56:13 -0500 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2009-04-14 15:56:13 -0500 |
commit | 11d4bfb18cb679b41e7d0b1b34b6e1a453de3591 (patch) | |
tree | d4cfd9f52cf5de2b676cb55a517df310d9606d95 | |
parent | 4839fe2e8201835a53ab6c75528a613e8bf25bfb (diff) | |
download | rails-11d4bfb18cb679b41e7d0b1b34b6e1a453de3591.tar.gz rails-11d4bfb18cb679b41e7d0b1b34b6e1a453de3591.tar.bz2 rails-11d4bfb18cb679b41e7d0b1b34b6e1a453de3591.zip |
We aren't using UploadedStringIO and UploadedTempfile anymore
-rw-r--r-- | actionpack/lib/action_controller.rb | 3 | ||||
-rw-r--r-- | actionpack/lib/action_dispatch.rb | 4 | ||||
-rwxr-xr-x | actionpack/lib/action_dispatch/http/request.rb | 28 | ||||
-rw-r--r-- | actionpack/lib/action_dispatch/utils/uploaded_file.rb | 44 |
4 files changed, 28 insertions, 51 deletions
diff --git a/actionpack/lib/action_controller.rb b/actionpack/lib/action_controller.rb index 1c01aaa277..16d19d91b9 100644 --- a/actionpack/lib/action_controller.rb +++ b/actionpack/lib/action_controller.rb @@ -73,9 +73,6 @@ module ActionController autoload :UrlRewriter, 'action_controller/routing/generation/url_rewriter' autoload :UrlWriter, 'action_controller/routing/generation/url_rewriter' autoload :Verification, 'action_controller/base/verification' - autoload :UploadedFile, 'action_dispatch/utils/uploaded_file' - autoload :UploadedStringIO, 'action_dispatch/utils/uploaded_file' - autoload :UploadedTempfile, 'action_dispatch/utils/uploaded_file' module Assertions autoload :DomAssertions, 'action_controller/testing/assertions/dom' diff --git a/actionpack/lib/action_dispatch.rb b/actionpack/lib/action_dispatch.rb index b4fdaafbfc..98ebdc72e3 100644 --- a/actionpack/lib/action_dispatch.rb +++ b/actionpack/lib/action_dispatch.rb @@ -49,10 +49,6 @@ module ActionDispatch autoload :RewindableInput, 'action_dispatch/middleware/rewindable_input' autoload :MiddlewareStack, 'action_dispatch/utils/middleware_stack' - autoload :UploadedFile, 'action_dispatch/utils/uploaded_file' - autoload :UploadedStringIO, 'action_dispatch/utils/uploaded_file' - autoload :UploadedTempfile, 'action_dispatch/utils/uploaded_file' - autoload :UrlEncodedPairParser, 'action_dispatch/utils/url_encoded_pair_parser' module Http autoload :Headers, 'action_dispatch/http/headers' diff --git a/actionpack/lib/action_dispatch/http/request.rb b/actionpack/lib/action_dispatch/http/request.rb index 7d47a1566e..523ab32b35 100755 --- a/actionpack/lib/action_dispatch/http/request.rb +++ b/actionpack/lib/action_dispatch/http/request.rb @@ -477,6 +477,34 @@ EOM !(host.nil? || /\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.match(host)) end + module UploadedFile + def self.extended(object) + object.class_eval do + attr_accessor :original_path, :content_type + alias_method :local_path, :path + end + end + + # Take the basename of the upload's original filename. + # This handles the full Windows paths given by Internet Explorer + # (and perhaps other broken user agents) without affecting + # those which give the lone filename. + # The Windows regexp is adapted from Perl's File::Basename. + def original_filename + unless defined? @original_filename + @original_filename = + unless original_path.blank? + if original_path =~ /^(?:.*[:\\\/])?(.*)/m + $1 + else + File.basename original_path + end + end + end + @original_filename + end + end + # Convert nested Hashs to HashWithIndifferentAccess and replace # file upload hashs with UploadedFile objects def normalize_parameters(value) diff --git a/actionpack/lib/action_dispatch/utils/uploaded_file.rb b/actionpack/lib/action_dispatch/utils/uploaded_file.rb deleted file mode 100644 index 97dffa089f..0000000000 --- a/actionpack/lib/action_dispatch/utils/uploaded_file.rb +++ /dev/null @@ -1,44 +0,0 @@ -module ActionDispatch - module UploadedFile - def self.included(base) - base.class_eval do - attr_accessor :original_path, :content_type - alias_method :local_path, :path - end - end - - def self.extended(object) - object.class_eval do - attr_accessor :original_path, :content_type - alias_method :local_path, :path - end - end - - # Take the basename of the upload's original filename. - # This handles the full Windows paths given by Internet Explorer - # (and perhaps other broken user agents) without affecting - # those which give the lone filename. - # The Windows regexp is adapted from Perl's File::Basename. - def original_filename - unless defined? @original_filename - @original_filename = - unless original_path.blank? - if original_path =~ /^(?:.*[:\\\/])?(.*)/m - $1 - else - File.basename original_path - end - end - end - @original_filename - end - end - - class UploadedStringIO < StringIO - include UploadedFile - end - - class UploadedTempfile < Tempfile - include UploadedFile - end -end |