Class: Faraday::Parts::FilePart
- Inherits:
-
Object
- Object
- Faraday::Parts::FilePart
- Defined in:
- lib/faraday/parts/filepart.rb
Overview
monkey patch from @liluo gist.github.com/4176272
Instance Method Summary collapse
-
#initialize(boundary, name, io) ⇒ FilePart
constructor
A new instance of FilePart.
Constructor Details
#initialize(boundary, name, io) ⇒ FilePart
Returns a new instance of FilePart.
4 5 6 7 8 9 10 |
# File 'lib/faraday/parts/filepart.rb', line 4 def initialize(boundary, name, io) file_length = io.respond_to?(:length) ? io.length : File.size(io.local_path) @head = build_head(boundary, name, io.original_filename, io.content_type, file_length, io.respond_to?(:opts) ? io.opts : {}) @length = @head.length + file_length @io = CompositeReadIO.new(StringIO.new(@head), io, StringIO.new("\r\n")) end |