maxwell v2.3.0 Maxwell.Multipart

Process mutipart for adapter

Link to this section Summary

Link to this section Types

Link to this type

boundary_t()

boundary_t() :: String.t()
Link to this type

disposition_t()

disposition_t() :: {String.t(), params_t()}
Link to this type

file_content_t()

file_content_t() :: binary()
Link to this type

header_t()

header_t() :: {String.t(), String.t()} | {String.t(), String.t(), params_t()}
Link to this type

headers_t()

headers_t() :: Keyword.t()
Link to this type

name_t()

name_t() :: String.t()
Link to this type

param_t()

param_t() :: {String.t(), String.t()}
Link to this type

params_t()

params_t() :: [param_t()]
Link to this type

part_t()

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()}
Link to this type

t()

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

Link to this section Functions

Link to this function

add_field(multipart, name, value)

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

add_field(multipart, name, value, extra_headers)

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

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

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

add_file(multipart, path)

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

add_file(multipart, path, extra_headers)

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

add_file(multipart, path, disposition, extra_headers)

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

add_file_content(multipart, file_content, filename)

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

add_file_content(multipart, file_content, filename, extra_headers)

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)

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 \\ [])

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 \\ [])

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

encode_form(parts)

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)

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)

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)

Link to this function

new()

new() :: t()

create a multipart struct

Link to this function

new_boundary()

new_boundary() :: boundary_t()

Return a random boundary(binary)

Examples

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