nova_multipart_handler behaviour (nova v0.18.1)

View Source

Behaviour for a nova_multipart_plugin file sink, configured as {Mod, InitArgs}. Chunks arrive straight off the socket, so a handler that writes each one away keeps memory flat regardless of upload size.

Every field of part_info() is client controlled. Never build a filesystem path from filename and never trust content_type.

Summary

Types

part_info()

-type part_info() :: #{name := binary(), filename := binary(), content_type := binary()}.

Callbacks

handle_abort(Reason, HandlerState)

-callback handle_abort(Reason :: term(), HandlerState :: term()) -> ok.

handle_data(Data, HandlerState)

-callback handle_data(Data :: binary(), HandlerState :: term()) ->
                         {ok, NewHandlerState :: term()} | {error, Reason :: term()}.

handle_end(HandlerState)

-callback handle_end(HandlerState :: term()) -> {ok, Result :: term()} | {error, Reason :: term()}.

init(PartInfo, InitArgs)

-callback init(PartInfo :: part_info(), InitArgs :: term()) ->
                  {ok, HandlerState :: term()} | {reject, Reason :: term()} | {error, Reason :: term()}.