Class: ActionDispatch::Http::UploadedFile

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

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (UploadedFile) initialize(hash)

A new instance of UploadedFile

Raises:

  • (ArgumentError)


8
9
10
11
12
13
14
# File 'actionpack/lib/action_dispatch/http/upload.rb', line 8

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

Instance Attribute Details

- (Object) content_type

Returns the value of attribute content_type



6
7
8
# File 'actionpack/lib/action_dispatch/http/upload.rb', line 6

def content_type
  @content_type
end

- (Object) headers

Returns the value of attribute headers



6
7
8
# File 'actionpack/lib/action_dispatch/http/upload.rb', line 6

def headers
  @headers
end

- (Object) original_filename

Returns the value of attribute original_filename



6
7
8
# File 'actionpack/lib/action_dispatch/http/upload.rb', line 6

def original_filename
  @original_filename
end

- (Object) tempfile

Returns the value of attribute tempfile



6
7
8
# File 'actionpack/lib/action_dispatch/http/upload.rb', line 6

def tempfile
  @tempfile
end

Instance Method Details

- (Object) read(*args)



16
17
18
# File 'actionpack/lib/action_dispatch/http/upload.rb', line 16

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

- (Object) rewind



20
21
22
# File 'actionpack/lib/action_dispatch/http/upload.rb', line 20

def rewind
  @tempfile.rewind
end

- (Object) size



24
25
26
# File 'actionpack/lib/action_dispatch/http/upload.rb', line 24

def size
  @tempfile.size
end