Class: ActionDispatch::Http::UploadedFile

Inherits:
Object
  • Object
show all
Defined in:
lib/action_dispatch/http/upload.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ UploadedFile

Returns a new instance of UploadedFile.

Raises:

  • (ArgumentError)


6
7
8
9
10
11
12
# File 'lib/action_dispatch/http/upload.rb', line 6

def initialize(hash)
  @original_filename = encode_filename(hash[:filename])
  @content_type      = hash[:type]
  @headers           = hash[:head]
  @tempfile          = hash[:tempfile]
  raise(ArgumentError, ':tempfile is required') unless @tempfile
end

Instance Attribute Details

#content_typeObject

Returns the value of attribute content_type.



4
5
6
# File 'lib/action_dispatch/http/upload.rb', line 4

def content_type
  @content_type
end

#headersObject

Returns the value of attribute headers.



4
5
6
# File 'lib/action_dispatch/http/upload.rb', line 4

def headers
  @headers
end

#original_filenameObject

Returns the value of attribute original_filename.



4
5
6
# File 'lib/action_dispatch/http/upload.rb', line 4

def original_filename
  @original_filename
end

#tempfileObject

Returns the value of attribute tempfile.



4
5
6
# File 'lib/action_dispatch/http/upload.rb', line 4

def tempfile
  @tempfile
end

Instance Method Details

#read(*args) ⇒ Object



14
15
16
# File 'lib/action_dispatch/http/upload.rb', line 14

def read(*args)
  @tempfile.read(*args)
end