class ActionDispatch::Http::UploadedFile

Parent:
Object

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

content_type[RW]

A string with the MIME type of the file.

headers[RW]

A string with the headers of the multipart request.

original_filename[RW]

The basename of the file in the client.

tempfile[RW]

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

Public Instance Methods

close(unlink_now = false) Show source
# File actionpack/lib/action_dispatch/http/upload.rb, line 58
def close(unlink_now = false)
  @tempfile.close(unlink_now)
end

Shortcut for tempfile.close.

eof?() Show source
# File actionpack/lib/action_dispatch/http/upload.rb, line 83
def eof?
  @tempfile.eof?
end

Shortcut for tempfile.eof?.

open() Show source
# File actionpack/lib/action_dispatch/http/upload.rb, line 53
def open
  @tempfile.open
end

Shortcut for tempfile.open.

path() Show source
# File actionpack/lib/action_dispatch/http/upload.rb, line 63
def path
  @tempfile.path
end

Shortcut for tempfile.path.

read(length = nil, buffer = nil) Show source
# File actionpack/lib/action_dispatch/http/upload.rb, line 48
def read(length = nil, buffer = nil)
  @tempfile.read(length, buffer)
end

Shortcut for tempfile.read.

rewind() Show source
# File actionpack/lib/action_dispatch/http/upload.rb, line 73
def rewind
  @tempfile.rewind
end

Shortcut for tempfile.rewind.

size() Show source
# File actionpack/lib/action_dispatch/http/upload.rb, line 78
def size
  @tempfile.size
end

Shortcut for tempfile.size.

to_io() Show source
# File actionpack/lib/action_dispatch/http/upload.rb, line 87
def to_io
  @tempfile.to_io
end
to_path() Show source
# File actionpack/lib/action_dispatch/http/upload.rb, line 68
def to_path
  @tempfile.to_path
end

Shortcut for tempfile.to_path.

© 2004–2019 David Heinemeier Hansson
Licensed under the MIT License.