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.
Methods
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 |
[RW] | to_io | A |
Instance Public methods
close(unlink_now = false)
Shortcut for tempfile.close
.
📝 Source code
# File actionpack/lib/action_dispatch/http/upload.rb, line 59
def close(unlink_now = false)
@tempfile.close(unlink_now)
end
🔎 See on GitHub
eof?()
Shortcut for tempfile.eof?
.
📝 Source code
# File actionpack/lib/action_dispatch/http/upload.rb, line 79
def eof?
@tempfile.eof?
end
🔎 See on GitHub
open()
Shortcut for tempfile.open
.
📝 Source code
# File actionpack/lib/action_dispatch/http/upload.rb, line 54
def open
@tempfile.open
end
🔎 See on GitHub
path()
Shortcut for tempfile.path
.
📝 Source code
# File actionpack/lib/action_dispatch/http/upload.rb, line 64
def path
@tempfile.path
end
🔎 See on GitHub
read(length = nil, buffer = nil)
Shortcut for tempfile.read
.
📝 Source code
# File actionpack/lib/action_dispatch/http/upload.rb, line 49
def read(length = nil, buffer = nil)
@tempfile.read(length, buffer)
end
🔎 See on GitHub
rewind()
Shortcut for tempfile.rewind
.
📝 Source code
# File actionpack/lib/action_dispatch/http/upload.rb, line 69
def rewind
@tempfile.rewind
end
🔎 See on GitHub
size()
Shortcut for tempfile.size
.
📝 Source code
# File actionpack/lib/action_dispatch/http/upload.rb, line 74
def size
@tempfile.size
end
🔎 See on GitHub