Skip to Content Skip to Search

class ActionDispatch::Http::UploadedFile

Action Dispatch HTTP UploadedFile

Models uploaded files.

The actual file is accessible via the tempfile accessor, though some of its interface is available directly for convenience.

Uploaded files are temporary files whose lifespan is one request. When the object is finalized Ruby unlinks the file, so there is no need to clean them with a separate maintenance task.

Attributes

[RW] content_type

A string with the MIME type of the file.

[RW] headers

A string with the headers of the multipart request.

[RW] original_filename

The basename of the file in the client.

[RW] tempfile

A Tempfile object with the actual uploaded file. Note that some of its interface is available directly.

Public instance methods

close(unlink_now = false)

Permalink

Shortcut for tempfile.close.

Source code GitHub
# File actionpack/lib/action_dispatch/http/upload.rb, line 71
def close(unlink_now = false)
  @tempfile.close(unlink_now)
end

eof?()

Permalink

Shortcut for tempfile.eof?.

Source code GitHub
# File actionpack/lib/action_dispatch/http/upload.rb, line 96
def eof?
  @tempfile.eof?
end

open()

Permalink

Shortcut for tempfile.open.

Source code GitHub
# File actionpack/lib/action_dispatch/http/upload.rb, line 66
def open
  @tempfile.open
end

path()

Permalink

Shortcut for tempfile.path.

Source code GitHub
# File actionpack/lib/action_dispatch/http/upload.rb, line 76
def path
  @tempfile.path
end

read(length = nil, buffer = nil)

Permalink

Shortcut for tempfile.read.

Source code GitHub
# File actionpack/lib/action_dispatch/http/upload.rb, line 61
def read(length = nil, buffer = nil)
  @tempfile.read(length, buffer)
end

rewind()

Permalink

Shortcut for tempfile.rewind.

Source code GitHub
# File actionpack/lib/action_dispatch/http/upload.rb, line 86
def rewind
  @tempfile.rewind
end

size()

Permalink

Shortcut for tempfile.size.

Source code GitHub
# File actionpack/lib/action_dispatch/http/upload.rb, line 91
def size
  @tempfile.size
end

to_io()

Permalink
Source code GitHub
# File actionpack/lib/action_dispatch/http/upload.rb, line 100
def to_io
  @tempfile.to_io
end

to_path()

Permalink

Shortcut for tempfile.to_path.

Source code GitHub
# File actionpack/lib/action_dispatch/http/upload.rb, line 81
def to_path
  @tempfile.to_path
end

Definition files