我生成一个xml并将其存储到某个位置说myproject/media/doc.xml
因为我是erlang的新手开发者。我所知道的是我必须设置像
"Content-Disposition", "attachment; filename=\"" + Filename + "\""
但我不确定如何通过ChicagoBoss实现这一目标。 我按照链接:
但我仍然没有明白如何做到这一点。我们试图做的是:
download_xml('GET', [])->
Fun = fun (Socket, Transport) ->
Transport:sendfile(Socket, "/home/laxmikant/Desktop/demo.xml")
end,
Req2 = cowboy_req:set_resp_body_fun( F, Req),%% Req is available here
Req3 = cowboy_req:set_resp_header(<<"Content-Disposition">>, "GET", Req2),
Req4 = cowboy_req:set_resp_header(<<"attachment;filename=\"demo.xml\"">>, "GET", Req3),
Req5 = cowboy_req:set_resp_header(<<"Content-Length">>, "GET", Req4),
Req6 = cowboy_req:set_resp_header(<<"1024">>, "GET", Req5),
cowboy_req:reply(200, [
{<<"content-type">>, <<"application/octet-stream">>}
], "", Req6).
但似乎是ChicagoBoss Request对象与Cowboy Req不匹配。