Class: BreezyPDF::Uploads::FileFormData

Inherits:
Object
  • Object
show all
Defined in:
lib/breezy_pdf/uploads/file_form_data.rb

Overview

Compose the form data for an HTTP POST of a file

Instance Method Summary collapse

Constructor Details

#initialize(fields, content_type, filename, file) ⇒ FileFormData

Returns a new instance of FileFormData.



8
9
10
11
12
13
# File 'lib/breezy_pdf/uploads/file_form_data.rb', line 8

def initialize(fields, content_type, filename, file)
  @fields       = fields
  @content_type = content_type
  @filename     = filename
  @file         = file
end

Instance Method Details

#boundaryObject



23
24
25
# File 'lib/breezy_pdf/uploads/file_form_data.rb', line 23

def boundary
  @boundary ||= SecureRandom.hex
end

#dataObject



15
16
17
18
19
20
21
# File 'lib/breezy_pdf/uploads/file_form_data.rb', line 15

def data
  @data ||= [
    field_data,
    file_data,
    closing_data
  ].join
end