Debian Codegraph @

examples/upload/src/upload_h.erl

raw
1 %% Feel free to use, reuse and abuse the code in this file.
2
3 %% @doc Upload handler.
4 -module(upload_h).
5
6 -export([init/2]).
7
8 init(Req, Opts) ->
9 {ok, Headers, Req2} = cowboy_req:read_part(Req),
10 {ok, Data, Req3} = cowboy_req:read_part_body(Req2),
11 {file, <<"inputfile">>, Filename, ContentType}
12 = cow_multipart:form_data(Headers),
13 io:format("Received file ~p of content-type ~p as follow:~n~p~n~n",
14 [Filename, ContentType, Data]),
15 {ok, Req3, Opts}.