|
|
@ -9,6 +9,8 @@ require_relative 'html' |
|
|
|
|
|
|
|
module Landline |
|
|
|
module Util |
|
|
|
FormPart = Struct.new(:data, :name, :filename, |
|
|
|
:filetype, :tempfile, :headers) |
|
|
|
# Valid element of form data with headers |
|
|
|
# @!attribute headers [Hash] headers recevied from form data |
|
|
|
# @!attribute name [String] name of the form part |
|
|
@ -16,8 +18,7 @@ module Landline |
|
|
|
# @!attribute filename [String,nil] Original name of the sent file |
|
|
|
# @!attribute filetype [String,nil] MIME-type of the file |
|
|
|
# @!attribute tempfile [File,nil] Temporary file for storing sent file data. |
|
|
|
FormPart = Struct.new(:data, :name, :filename, |
|
|
|
:filetype, :tempfile, :headers) do |
|
|
|
class FormPart |
|
|
|
# Is this form part a file or plain data? |
|
|
|
# @return [Boolean] |
|
|
|
def file? |
|
|
@ -135,7 +136,8 @@ module Landline |
|
|
|
end |
|
|
|
|
|
|
|
# Setup file metadata |
|
|
|
# @part part [FormPart] |
|
|
|
# @param part [Landline::Util::FormPart] |
|
|
|
# @return [void] |
|
|
|
def setup_file_meta(part) |
|
|
|
part.name = part.headers.dig("content-disposition", 1, "name") |
|
|
|
part.filename = part.headers.dig("content-disposition", 1, "filename") |
|
|
@ -144,7 +146,8 @@ module Landline |
|
|
|
end |
|
|
|
|
|
|
|
# Setup plain metadata |
|
|
|
# @part part [FormPart] |
|
|
|
# @param part [Landline::Util::FormPart] |
|
|
|
# @return [void] |
|
|
|
def setup_data_meta(part) |
|
|
|
part.name = part.headers.dig("content-disposition", 1, "name") |
|
|
|
end |
|
|
|