Download/respond with binary data

22 views
Skip to first unread message

Maarten Koopmans

unread,
Sep 11, 2012, 9:07:06 AM9/11/12
to golang...@googlegroups.com
Hi,

Is there a way to respond to a GET with offering a download of binary data?

E.g. get /mydata/data.blob  returns "data.blob" as a binary stream to the client ( where we set the content type as well).

--Maarten

matryer

unread,
Sep 13, 2012, 5:40:38 AM9/13/12
to golang...@googlegroups.com
Goweb gets out of your way.  Once you've mapped the URL successfully to the func that will handle it, you can directly use Context.Request and Context.ResponseWriter to do whatever you like.

So the question becomes, How do I deliver binary content using Go's http package.  This might help: http://blog.golang.org/2011/03/gobs-of-data.html

Setting the content type is as simple as setting the appropriate value in Context.ResponseWriter.Header.

Mat

Maarten Koopmans

unread,
Sep 20, 2012, 8:09:50 AM9/20/12
to golang...@googlegroups.com
Thanks!

Op donderdag 13 september 2012 11:40:38 UTC+2 schreef matryer het volgende:
Reply all
Reply to author
Forward
0 new messages