Module ActionController::UploadedFile
In: vendor/rails/actionpack/lib/action_controller/uploaded_file.rb

Methods

Public Class methods

[Source]

    # File vendor/rails/actionpack/lib/action_controller/uploaded_file.rb, line 10
10:     def self.extended(object)
11:       object.class_eval do
12:         attr_accessor :original_path, :content_type
13:         alias_method :local_path, :path if method_defined?(:path)
14:       end
15:     end

[Source]

   # File vendor/rails/actionpack/lib/action_controller/uploaded_file.rb, line 3
3:     def self.included(base)
4:       base.class_eval do
5:         attr_accessor :original_path, :content_type
6:         alias_method :local_path, :path if method_defined?(:path)
7:       end
8:     end

Public Instance methods

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.

[Source]

    # File vendor/rails/actionpack/lib/action_controller/uploaded_file.rb, line 22
22:     def original_filename
23:       unless defined? @original_filename
24:         @original_filename =
25:           unless original_path.blank?
26:             if original_path =~ /^(?:.*[:\\\/])?(.*)/m
27:               $1
28:             else
29:               File.basename original_path
30:             end
31:           end
32:       end
33:       @original_filename
34:     end

[Validate]