How to send a PDF file in a response?

906 views
Skip to first unread message

Mike Funaro

unread,
Nov 17, 2014, 1:52:23 PM11/17/14
to ruby-...@googlegroups.com
Like the subject says, I am trying to figure out how to send a PDF in a Grape response. Does anyone have information on this or any links to tutorials or code that achieves this?

Mike Funaro

unread,
Nov 17, 2014, 6:13:55 PM11/17/14
to ruby-...@googlegroups.com
A coworker helped me figure this out, using the following...

          content_type "application/pdf"
          header
['Content-Disposition'] = "attachment; filename=#{filename}"
          env
['api.format'] = :binary
          body pdf
.render

Daniel Doubrovkine

unread,
Nov 18, 2014, 9:00:01 AM11/18/14
to ruby-...@googlegroups.com
You shouldn't need `env['api.format'] = :binary`, in theory `content_type` should be enough as long as you declare the pdf content-type.

--
You received this message because you are subscribed to the Google Groups "Grape Framework Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ruby-grape+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Reply all
Reply to author
Forward
0 new messages