Class: Rack::Multipart::UploadedFile
Relationships & Source Files | |
Inherits: | Object |
Defined in: | lib/rack/multipart/uploaded_file.rb |
Class Method Summary
Instance Attribute Summary
-
#content_type
rw
The content type of the “uploaded” file.
-
#original_filename
readonly
The filename, not including the path, of the “uploaded” file.
Instance Method Summary
-
#local_path
Alias for #path.
- #path (also: #local_path)
- #respond_to?(*args) ⇒ Boolean
- #method_missing(method_name, *args, &block) Internal use only
Constructor Details
.new(filepath = nil, ct = "text/plain", bin = false, path: filepath, content_type: ct, binary: bin, filename: nil, io: nil) ⇒ UploadedFile
# File 'lib/rack/multipart/uploaded_file.rb', line 16
def initialize(filepath = nil, ct = "text/plain", bin = false, path: filepath, content_type: ct, binary: bin, filename: nil, io: nil) if io @tempfile = io @original_filename = filename else raise "#{path} file does not exist" unless ::File.exist?(path) @original_filename = filename || ::File.basename(path) @tempfile = Tempfile.new([@original_filename, ::File.extname(path)], encoding: Encoding::BINARY) @tempfile.binmode if binary FileUtils.copy_file(path, @tempfile.path) end @content_type = content_type end
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block)
This method is for internal use only.
[ GitHub ]
# File 'lib/rack/multipart/uploaded_file.rb', line 40
def method_missing(method_name, *args, &block) #:nodoc: @tempfile.__send__(method_name, *args, &block) end
Instance Attribute Details
#content_type (rw)
The content type of the “uploaded” file
# File 'lib/rack/multipart/uploaded_file.rb', line 14
attr_accessor :content_type
#original_filename (readonly)
The filename, not including the path, of the “uploaded” file
# File 'lib/rack/multipart/uploaded_file.rb', line 11
attr_reader :original_filename
Instance Method Details
#local_path
Alias for #path.
# File 'lib/rack/multipart/uploaded_file.rb', line 34
alias_method :local_path, :path
#path Also known as: #local_path
[ GitHub ]# File 'lib/rack/multipart/uploaded_file.rb', line 31
def path @tempfile.path if @tempfile.respond_to?(:path) end
#respond_to?(*args) ⇒ Boolean
# File 'lib/rack/multipart/uploaded_file.rb', line 36
def respond_to?(*args) super or @tempfile.respond_to?(*args) end