Send file to Jruby / JRack Tomcat

I had an interesting problem when deploying an application to Tomcat. I'm using Stone Acts_as_flying_saucer to convert html to pdf. What kind of gem / plugin does render the html view and then uses the Java SAX processor to render a standard PDF / 1.4 file compatible with the TMP server.

The problem I am facing is when the plugin makes a call to send the file to the browser. It sends a 0 byte file. Looking at the Rails magazine, he says he sent / tmp / 41c986f5e6249ce24c7698b6494796e0.pdf

Tomcat log shows 200 status as if it had sent a file. But the file in the directory / tmp / has information, and the one sent to the browser is empty.

The best thing I have is that there is something flaky in the send_file file Method.

It works great with webrick. I deployed WAR to several different Tomcat Instances on both Linux and Windows ... the logs seem to show everything is working fine.

Let me know if I need more information or who has ideas on how I can track this issue.

Thanks, Jim

+3
source share
2 answers

It seems that Tomcat does not understand the "X-Sendfile", as other web servers do.

"Fix" is a comment:

config.action_dispatch.x_sendfile_header = "X-Sendfile"

in your environment /production.rb

Hope this helps others.

-Jeet

+3
source

You can also add this middleware to your middleware stack.

https://gist.github.com/958096

+1
source

All Articles