hecate_plugin_files (hecate_sdk v0.6.2)
View SourceFile upload/download helper for plugins.
Handles multipart uploads and chunked downloads via cowboy. Files are stored under the plugin's data directory.
Summary
Functions
Read the full request body (up to 8MB default).
Read the full request body with custom options.
Save uploaded binary data to a file in the plugin's data directory.
Stream a file as the response body (chunked transfer).
Functions
-spec read_body(cowboy_req:req()) -> {ok, binary(), cowboy_req:req()}.
Read the full request body (up to 8MB default).
-spec read_body(cowboy_req:req(), map()) -> {ok, binary(), cowboy_req:req()}.
Read the full request body with custom options.
-spec save_upload(PluginName :: string() | binary(), RelativePath :: string(), Data :: binary()) -> ok | {error, term()}.
Save uploaded binary data to a file in the plugin's data directory.
-spec stream_file(cowboy_req:req(), file:filename(), binary()) -> {ok, cowboy_req:req()}.
Stream a file as the response body (chunked transfer).