Class: ActionDispatch::Http::UploadedFile
- Defined in:
- runtime/action_dispatch/multipart.rb,
runtime/action_dispatch/multipart.rbs
Overview
A multipart part, and what fixture_file_upload hands a test: the name
it was uploaded under, its declared type, and its bytes. Data-backed
rather than file-backed so a part never touches the disk before the
storage service decides where it lives.
Instance Attribute Summary collapse
-
#content_type ⇒ String
readonly
Returns the value of attribute content_type.
-
#original_filename ⇒ String
readonly
Returns the value of attribute original_filename.
Class Method Summary collapse
-
.from_params(sub, key) ⇒ UploadedFile?
the file under
keyin a params sub-hash, or nil when the request carried no file there (absent, or a text field — the bare filename a urlencoded form posts for a file input is a String, not a file). -
.name_of(file) ⇒ String
the uploaded name for a params record's
to_h, or "" for none. -
.provided(sub, key) ⇒ Boolean
did the request carry a file under
key? The file counterpart ofActionController::Params.provided.
Instance Method Summary collapse
-
#initialize(data, original_filename, content_type) ⇒ UploadedFile
constructor
A new instance of UploadedFile.
- #read ⇒ String
- #size ⇒ Integer
-
#to_s ⇒ String
the uploaded name, which is what a params hash carrying this file stringifies to.
Constructor Details
#initialize(data, original_filename, content_type) ⇒ UploadedFile
Returns a new instance of UploadedFile.
9 |
# File 'runtime/action_dispatch/multipart.rbs', line 9
def initialize: (String data, String original_filename, String content_type) -> void
|
Instance Attribute Details
#content_type ⇒ String (readonly)
Returns the value of attribute content_type.
8 9 10 |
# File 'runtime/action_dispatch/multipart.rbs', line 8 def content_type @content_type end |
#original_filename ⇒ String (readonly)
Returns the value of attribute original_filename.
7 8 9 |
# File 'runtime/action_dispatch/multipart.rbs', line 7 def original_filename @original_filename end |
Class Method Details
.from_params(sub, key) ⇒ UploadedFile?
the file under key in a params sub-hash, or nil when the request
carried no file there (absent, or a text field — the bare filename a
urlencoded form posts for a file input is a String, not a file).
58 |
# File 'runtime/action_dispatch/multipart.rb', line 58
def self.from_params: (Hash[String, untyped] sub, String key) -> ActionDispatch::Http::UploadedFile?
|
.name_of(file) ⇒ String
the uploaded name for a params record's to_h, or "" for none.
81 |
# File 'runtime/action_dispatch/multipart.rb', line 81
def self.name_of: (ActionDispatch::Http::UploadedFile? file) -> String
|
.provided(sub, key) ⇒ Boolean
did the request carry a file under key? The file counterpart of
ActionController::Params.provided.
73 |
# File 'runtime/action_dispatch/multipart.rb', line 73
def self.provided: (Hash[String, untyped] sub, String key) -> bool
|
Instance Method Details
#to_s ⇒ String
the uploaded name, which is what a params hash carrying this file stringifies to.
47 |
# File 'runtime/action_dispatch/multipart.rb', line 47
def to_s: () -> String
|