chicagoboss

How to read from post param?

丶灬走出姿态 提交于 2019-12-25 02:44:11
问题 I need to parse text file. This file is in post param. I have code like this: upload_file('POST', []) -> File = Req:post_param("file"), What should I do next? How to parse it? 回答1: What's inside Req:post_param("file") ? You assume it's a path to a file: have you checked the value of File ? Anyway, it's Req:post_files/0 you are probably looking for: [{_, _FileName, TempLocation, _Size}|_] = Req:post_files(), {ok,Data} = file:read_file(TempLocation), It's also probably a Bad Idea to leave the

Why chunk is returning some code while reading the file in Erlang/ChicagoBoss

旧时模样 提交于 2019-12-12 01:56:02
问题 Further to my old question, We are generating XML using following code: download_xml('GET', [])-> Xml =generateXML(123445), %% generated Xml data in string without any values 400,.etc Filename = export_xml:get_file_name(?SESSION_ID1, ?SESSION_ID2), Filepath = "./priv/static/" ++ Filename, TotalSize = filelib:file_size(Filepath), {ok, FP} = file:open(Filepath, [read]), Generator = fun(FH) -> case file:read(FH, 1024) of %% But this line is causing something that we never wanted. eof -> file

How to allow user to download a file in ChicagoBoss

南楼画角 提交于 2019-12-02 10:20:32
问题 I generate one xml and store it to some location say myproject/media/doc.xml As I'm newbie developer with erlang. What I knew is I will have to set request headers like "Content-Disposition", "attachment; filename=\"" + Filename + "\"" But I'm not sure how to achieve this with ChicagoBoss. I followed the links: How to download files in ChicagoBoss? how to download file by erlang cowboy? But still I did not get the clear idea about how to do that. What we tried to do is: download_xml('GET', []

How to allow user to download a file in ChicagoBoss

六眼飞鱼酱① 提交于 2019-12-02 06:49:50
I generate one xml and store it to some location say myproject/media/doc.xml As I'm newbie developer with erlang. What I knew is I will have to set request headers like "Content-Disposition", "attachment; filename=\"" + Filename + "\"" But I'm not sure how to achieve this with ChicagoBoss. I followed the links: How to download files in ChicagoBoss? how to download file by erlang cowboy? But still I did not get the clear idea about how to do that. What we tried to do is: download_xml('GET', [])-> Fun = fun (Socket, Transport) -> Transport:sendfile(Socket, "/home/laxmikant/Desktop/demo.xml") end