Sha256: 5106a2e28b6d625ed984a6e5f8f6dd7cebe04825ecd3f3c487bd7ddac21264aa

Contents?: true

Size: 495 Bytes

Versions: 3

Compression:

Stored size: 495 Bytes

Contents

# monkey patch from @liluo https://gist.github.com/4176272
class Faraday::Parts::FilePart
  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 
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
douban_api-0.1.2 lib/faraday/parts/filepart.rb
douban_api-0.1.1 lib/faraday/parts/filepart.rb
douban_api-0.1.0 lib/faraday/parts/filepart.rb