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"'
@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
Returns content size.
@return [Integer]
# File lib/http/form_data/part.rb, line 27 def size @body.bytesize end
Returns content of a file of IO.
@return [String]
# File lib/http/form_data/part.rb, line 34 def to_s @body end