How to download files in ChicagoBoss?

67 views
Skip to first unread message

Caiyun Deng

unread,
Aug 26, 2014, 10:56:58 PM8/26/14
to chica...@googlegroups.com
Hi!
I know how to upload file in ChicagoBoss.
But how to download file in ChicagoBoss? I want to show the file button in the page, and click the file then it will download the file.
Thanks!

Jesse Gumm

unread,
Aug 26, 2014, 11:16:54 PM8/26/14
to chica...@googlegroups.com
The easy way is to put your uploaded files into a directory in
/priv/static then any requests to
http://yoursite.com/static/some/path/your_new_file.bin

Otherwise, if your files are small, you could just have a controller
return {output, FileContents, Headers}, where FileContents could be
the result of file:read_file/1
(http://erldocs.com/17.0/kernel/file.html?i=0&search=file:read_file#read_file/1)

Ooootherwise, if your files are large, you can write a generator
function and return a streaming with with {stream, GeneratorFun, Acc}
(see http://chicagoboss.org/api-controller.html)

Hope that helps,

-Jesse
> --
> You received this message because you are subscribed to the Google Groups
> "ChicagoBoss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to chicagoboss...@googlegroups.com.
> Visit this group at http://groups.google.com/group/chicagoboss.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/chicagoboss/658e5727-2a37-4e1a-8e31-e05e6c13b5b3%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--
Jesse Gumm
Owner, Sigma Star Systems
414.940.4866 || sigma-star.com || @jessegumm

Caiyun Deng

unread,
Aug 27, 2014, 3:10:34 AM8/27/14
to chica...@googlegroups.com
Thanks!

在 2014年8月27日星期三UTC+8上午11时16分54秒,Jesse Gumm写道:
Reply all
Reply to author
Forward
0 new messages