Maxwell.Multipart (maxwell v2.4.0) View Source

Process mutipart for adapter

Link to this section Summary

Link to this section Types

Specs

boundary_t() :: String.t()

Specs

disposition_t() :: {String.t(), params_t()}

Specs

file_content_t() :: binary()

Specs

header_t() :: {String.t(), String.t()} | {String.t(), String.t(), params_t()}

Specs

headers_t() :: Keyword.t()

Specs

name_t() :: String.t()

Specs

param_t() :: {String.t(), String.t()}

Specs

params_t() :: [param_t()]

Specs

part_t() ::
  {:file, Path.t()}
  | {:file, Path.t(), headers_t()}
  | {:file, Path.t(), disposition_t(), headers_t()}
  | {:file_content, file_content_t(), String.t()}
  | {:file_content, file_content_t(), String.t(), headers_t()}
  | {:file_content, file_content_t(), String.t(), disposition_t(), headers_t()}
  | {:mp_mixed, String.t(), boundary_t()}
  | {:mp_mixed_eof, boundary_t()}
  | {name_t(), binary()}
  | {name_t(), binary(), headers_t()}
  | {name_t(), binary(), disposition_t(), headers_t()}

Specs

t() :: {:multipart, [part_t()]}

Link to this section Functions

Link to this function

add_field(multipart, name, value)

View Source

Specs

add_field(t(), String.t(), binary()) :: t()
Link to this function

add_field(multipart, name, value, extra_headers)

View Source

Specs

add_field(t(), String.t(), binary(), headers_t()) :: t()
Link to this function

add_field(multipart, name, value, disposition, extra_headers)

View Source

Specs

add_field(t(), String.t(), binary(), disposition_t(), headers_t()) :: t()
Link to this function

add_file(multipart, path)

View Source

Specs

add_file(t(), Path.t()) :: t()
Link to this function

add_file(multipart, path, extra_headers)

View Source

Specs

add_file(t(), Path.t(), headers_t()) :: t()
Link to this function

add_file(multipart, path, disposition, extra_headers)

View Source

Specs

add_file(t(), Path.t(), disposition_t(), headers_t()) :: t()
Link to this function

add_file_content(multipart, file_content, filename)

View Source

Specs

add_file_content(t(), file_content_t(), String.t()) :: t()
Link to this function

add_file_content(multipart, file_content, filename, extra_headers)

View Source

Specs

add_file_content(t(), file_content_t(), String.t(), headers_t()) :: t()
Link to this function

add_file_content(multipart, file_content, filename, disposition, extra_headers)

View Source

Specs

add_file_content(
  t(),
  file_content_t(),
  String.t(),
  disposition_t(),
  headers_t()
) :: t()
Link to this function

add_file_content_with_name(multipart, file_content, filename, name, extra_headers \\ [])

View Source

Specs

add_file_content_with_name(
  t(),
  file_content_t(),
  String.t(),
  String.t(),
  headers_t()
) :: t()
Link to this function

add_file_with_name(multipart, path, name, extra_headers \\ [])

View Source

Specs

add_file_with_name(t(), Path.t(), String.t(), headers_t()) :: t()

Specs

encode_form(parts :: [part_t()]) :: {boundary_t(), integer()}

multipart form encode.

* `parts` - receives lists list's member format:

     1. `{:file, path}`
     2. `{:file, path, extra_headers}`
     3. `{:file, path, disposition, extra_headers}`
     4. `{:file_content, file_content, filename}`
     5. `{:file_content, file_content, filename, extra_headers}`
     6. `{:file_content, file_content, filename, disposition, extra_headers}`
     7. `{:mp_mixed, name, mixed_boundary}`
     8. `{:mp_mixed_eof, mixed_boundary}`
     9. `{name, bin_data}`
    10. `{name, bin_data, extra_headers}`
    11. `{name, bin_data, disposition, extra_headers}`

Returns {body_binary, size}

Link to this function

encode_form(boundary, parts)

View Source

Specs

encode_form(boundary :: boundary_t(), parts :: [part_t()]) ::
  {boundary_t(), integer()}

multipart form encode.

  • boundary - multipart boundary.

  • parts - receives lists list's member format:

    1. `{:file, path}`
    2. `{:file, path, extra_headers}`
    3. `{:file, path, disposition, extra_headers}`
    4. `{:file_content, file_content, filename}`
    5. `{:file_content, file_content, filename, extra_headers}`
    6. `{:file_content, file_content, filename, disposition, extra_headers}`
    7. `{:mp_mixed, name, mixed_boundary}`
    8. `{:mp_mixed_eof, mixed_boundary}`
    9. `{name, bin_data}`
    1. {name, bin_data, extra_headers}
    2. {name, bin_data, disposition, extra_headers}
Link to this function

len_mp_stream(boundary, parts)

View Source

Specs

len_mp_stream(boundary :: boundary_t(), parts :: [part_t()]) :: integer()

Get the size of a mp stream. Useful to calculate the content-length of a full multipart stream and send it as an identity

* `boundary` - multipart boundary
* `parts` - see `Maxwell.Multipart.encode_form`.

Returns stream size(integer)

Specs

new() :: t()

create a multipart struct

Specs

new_boundary() :: boundary_t()

Return a random boundary(binary)

Examples

  # "---------------------------mtynipxrmpegseog"
  boundary = new_boundary()