nova_multipart_plugin (nova v0.18.1)

View Source

Reads a multipart/form-data body and streams every file part to a nova_multipart_handler, chunk by chunk. Regular fields are collected under params and file parts under files, each as #{name, filename, content_type, result} where result is whatever the handler returned from handle_end/1.

Multipart fields win over params set by an earlier plugin, and a repeated field name keeps the last value. On a non-multipart request the plugin sets files to [] and params to #{} unless an earlier plugin already set it, so a controller can match both keys on every request that reaches it.

Summary

Functions

plugin_info()

-spec plugin_info() ->
                     #{title := binary(),
                       version := binary(),
                       url := binary(),
                       authors := [binary()],
                       description := binary(),
                       options := [{Key :: atom(), OptionDescription :: binary()}]}.

post_request(Req, Env, Options, State)

-spec post_request(Req :: cowboy_req:req(), Env :: any(), Options :: map(), State :: any()) ->
                      {ok, Req0 :: cowboy_req:req(), NewState :: any()}.

pre_request(Req, Env, Options, State)

-spec pre_request(Req :: cowboy_req:req(), Env :: any(), Options :: map(), State :: any()) ->
                     {ok, Req0 :: cowboy_req:req(), NewState :: any()} |
                     {stop, Req0 :: cowboy_req:req(), NewState :: any()}.