Class: ServiceStack::UploadFile
- Inherits:
-
Object
- Object
- ServiceStack::UploadFile
- Defined in:
- lib/servicestack/json_service_client.rb
Overview
A file uploaded in a multipart/form-data Request.
Its contents can be supplied as a String or any IO that responds to read,
e.g. a File or StringIO.
Instance Attribute Summary collapse
-
#content_type ⇒ Object
Returns the value of attribute content_type.
-
#field_name ⇒ Object
Returns the value of attribute field_name.
-
#file_name ⇒ Object
Returns the value of attribute file_name.
-
#stream ⇒ Object
Returns the value of attribute stream.
Instance Method Summary collapse
-
#contents ⇒ Object
The file contents to upload.
-
#initialize(field_name: 'file', file_name: nil, content_type: nil, stream: nil) ⇒ UploadFile
constructor
A new instance of UploadFile.
Constructor Details
#initialize(field_name: 'file', file_name: nil, content_type: nil, stream: nil) ⇒ UploadFile
Returns a new instance of UploadFile.
30 31 32 33 34 35 |
# File 'lib/servicestack/json_service_client.rb', line 30 def initialize(field_name: 'file', file_name: nil, content_type: nil, stream: nil) @field_name = field_name @file_name = file_name @content_type = content_type @stream = stream end |
Instance Attribute Details
#content_type ⇒ Object
Returns the value of attribute content_type.
28 29 30 |
# File 'lib/servicestack/json_service_client.rb', line 28 def content_type @content_type end |
#field_name ⇒ Object
Returns the value of attribute field_name.
28 29 30 |
# File 'lib/servicestack/json_service_client.rb', line 28 def field_name @field_name end |
#file_name ⇒ Object
Returns the value of attribute file_name.
28 29 30 |
# File 'lib/servicestack/json_service_client.rb', line 28 def file_name @file_name end |
#stream ⇒ Object
Returns the value of attribute stream.
28 29 30 |
# File 'lib/servicestack/json_service_client.rb', line 28 def stream @stream end |
Instance Method Details
#contents ⇒ Object
The file contents to upload.
38 39 40 41 42 43 |
# File 'lib/servicestack/json_service_client.rb', line 38 def contents return @stream unless @stream.respond_to?(:read) @stream.binmode if @stream.respond_to?(:binmode) @stream.read end |