Class: DistributedPress::Multipart
- Inherits:
-
Object
- Object
- DistributedPress::Multipart
- Defined in:
- lib/distributed_press/multipart.rb
Overview
Deals with multipart requests
Constant Summary collapse
- NEWLINE =
Newlines
"\r\n"
- BOUNDARY =
Boundary separator
'--'
Instance Method Summary collapse
-
#boundary ⇒ String
Generate a MultiPart boundary and reuse it.
-
#write_footer(io) ⇒ Object
Write the multipart footer.
-
#write_header(io, filename) ⇒ Object
Write the multipart header.
Instance Method Details
#boundary ⇒ String
Generate a MultiPart boundary and reuse it
47 48 49 |
# File 'lib/distributed_press/multipart.rb', line 47 def boundary @boundary ||= HTTParty::Request::MultipartBoundary.generate end |
#write_footer(io) ⇒ Object
Write the multipart footer
34 35 36 37 38 39 40 41 42 |
# File 'lib/distributed_press/multipart.rb', line 34 def (io) io.write NEWLINE io.write BOUNDARY io.write boundary io.write BOUNDARY io.write NEWLINE nil end |
#write_header(io, filename) ⇒ Object
Write the multipart header
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/distributed_press/multipart.rb', line 18 def write_header(io, filename) io.write BOUNDARY io.write boundary io.write NEWLINE io.write "Content-Disposition: form-data; name=\"file\"; filename=\"#{filename}\"" io.write NEWLINE io.write 'Content-Type: application/octet-stream' io.write NEWLINE io.write NEWLINE nil end |