class HTTP::FormData::Part

Represents a body part of multipart/form-data request.

@example Usage with String

body = "Message"
FormData::Part.new body, :content_type => 'foobar.txt; charset="UTF-8"'

Attributes

content_type[R]
filename[R]

Public Class Methods

new(body, opts = {}) click to toggle source

@param body [#to_s] @param opts [Hash] @option opts [String] :content_type Value of Content-Type header @option opts [String] :filename Value of filename parameter

# File lib/http/form_data/part.rb, line 18
def initialize(body, opts = {})
  @body = body.to_s
  @content_type = opts[:content_type]
  @filename = opts[:filename]
end

Public Instance Methods

size() click to toggle source

Returns content size.

@return [Integer]

# File lib/http/form_data/part.rb, line 27
def size
  @body.bytesize
end
to_s() click to toggle source

Returns content of a file of IO.

@return [String]

# File lib/http/form_data/part.rb, line 34
def to_s
  @body
end