class Docusigner::Multipart::Parts::DocumentPart

Attributes

length[R]

Public Class Methods

new(boundary, upload_io, opts = {}) click to toggle source
# File lib/docusigner/multipart.rb, line 62
def initialize(boundary, upload_io, opts = {})
  @upload_io = upload_io
  head = build(boundary, @upload_io, opts)
  foot = "\r\n"
  @output_io = CompositeReadIO.new(StringIO.new(head), @upload_io.io, StringIO.new(foot))
  @length = head.length + file_length + foot.length
end

Public Instance Methods

to_io() click to toggle source
# File lib/docusigner/multipart.rb, line 69
def to_io
  @output_io
end

Protected Instance Methods

build(boundary, io, opts = {}) click to toggle source
# File lib/docusigner/multipart.rb, line 78
def build(boundary, io, opts = {})
  [
    "--#{boundary}",
    %(Content-Type: #{io.content_type}),
    %(Content-Disposition: file; filename="#{opts[:name]}"; documentId=#{opts[:document_id]}),
    %(Content-Length: #{file_length}),
    "",
    ""
  ].join("\r\n")
end
file_length() click to toggle source
# File lib/docusigner/multipart.rb, line 74
def file_length
  @file_length ||= @upload_io.respond_to?(:length) ? @upload_io.length : File.size(@upload_io.local_path)
end