Serving dynamically generated contents as static download

100 views
Skip to first unread message

Anton Shvein

unread,
Nov 20, 2013, 2:34:41 AM11/20/13
to nitrogenweb
Hi,
Is there any way to push dynamically generated binary content as if it where regularly downloaded  binary file?

--
Sencerely yours, T0ha aka Shvein Anton.

Stuart Thackray

unread,
Nov 20, 2013, 3:01:55 AM11/20/13
to nitro...@googlegroups.com
Hi Toha,

  If I understand you correctly you are looking for http://nitrogenproject.com/demos/contenttype

  If that doesn't help let me know.

Regards,
Stuart

Jesse Gumm

unread,
Nov 24, 2013, 2:54:14 PM11/24/13
to nitrogenweb
Hi Anton!

If I'm understanding your needs (wanting to dynamically generate
streamed binary content), there isn't a great way to deal with this.
There are two ways to deal with this:

1) Using the underlying server's streaming mechanisms (such as making
a cowboy-specific dispatch table to targets a cowboy handler module to
deal with the streaming), or a yaws outfile.

2) Using cowboy, there's a bit of a hack that can work in
simple_bridge if you're using cowboy. If your module's main() function
returns the tuple: {stream, StreamFun} where StreamFun is a function
with arity 2 that (fun(Socket, Transport) - Transport being a ranch
transport). Really, this is just a shortcut way that allows you to
use Transport:send(socket) to send data. I'll admit I haven't done
this before, but it should work with a little bit of tinkering.

Adding this as an actual option to simple_bridge and Nitrogen would
probably be worthwhile.

If, however, you are just generating a small-ish amount of data, then
doing as Stuart recommends would be much easier.

-Jesse
> --
> You received this message because you are subscribed to the Google Groups
> "Nitrogen Project / The Nitrogen Web Framework for Erlang" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to nitrogenweb...@googlegroups.com.
> To post to this group, send email to nitro...@googlegroups.com.
> Visit this group at http://groups.google.com/group/nitrogenweb.
> For more options, visit https://groups.google.com/groups/opt_out.



--
Jesse Gumm
Owner, Sigma Star Systems
414.940.4866 || sigma-star.com || @jessegumm
Reply all
Reply to author
Forward
0 new messages