Class: Buble::FileUpload
- Inherits:
-
Object
- Object
- Buble::FileUpload
- Defined in:
- lib/buble/files.rb
Instance Attribute Summary collapse
-
#close_after ⇒ Object
readonly
Returns the value of attribute close_after.
-
#content_type ⇒ Object
readonly
Returns the value of attribute content_type.
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
-
#io ⇒ Object
readonly
Returns the value of attribute io.
Class Method Summary collapse
- .from_io(io, filename:, content_type: 'application/octet-stream') ⇒ Object
- .from_path(path, content_type: 'application/octet-stream') ⇒ Object
Instance Method Summary collapse
-
#initialize(io:, filename:, content_type: 'application/octet-stream', close_after: false) ⇒ FileUpload
constructor
A new instance of FileUpload.
- #to_http_part ⇒ Object
Constructor Details
#initialize(io:, filename:, content_type: 'application/octet-stream', close_after: false) ⇒ FileUpload
Returns a new instance of FileUpload.
7 8 9 10 11 12 |
# File 'lib/buble/files.rb', line 7 def initialize(io:, filename:, content_type: 'application/octet-stream', close_after: false) @io = io @filename = filename @content_type = content_type @close_after = close_after end |
Instance Attribute Details
#close_after ⇒ Object (readonly)
Returns the value of attribute close_after.
5 6 7 |
# File 'lib/buble/files.rb', line 5 def close_after @close_after end |
#content_type ⇒ Object (readonly)
Returns the value of attribute content_type.
5 6 7 |
# File 'lib/buble/files.rb', line 5 def content_type @content_type end |
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
5 6 7 |
# File 'lib/buble/files.rb', line 5 def filename @filename end |
#io ⇒ Object (readonly)
Returns the value of attribute io.
5 6 7 |
# File 'lib/buble/files.rb', line 5 def io @io end |
Class Method Details
.from_io(io, filename:, content_type: 'application/octet-stream') ⇒ Object
23 24 25 |
# File 'lib/buble/files.rb', line 23 def self.from_io(io, filename:, content_type: 'application/octet-stream') new(io: io, filename: filename, content_type: content_type, close_after: false) end |
.from_path(path, content_type: 'application/octet-stream') ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/buble/files.rb', line 14 def self.from_path(path, content_type: 'application/octet-stream') new( io: File.open(path, 'rb'), filename: File.basename(path), content_type: content_type, close_after: true ) end |