大佬教程收集整理的这篇文章主要介绍了ruby-on-rails – Rails 3,apache和passenger,send_file发送零字节文件,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
root~# a2enmod xsendfile Module xsendfile already enabled
它已启用mods正确符号
lrwxrwxrwx 1 root root 32 Aug 8 11:20 xsendfile.load -> ../mods-available/xsendfile.load
config.action_dispatch.x_sendfile_header =“X-Sendfile”在我的production.rb中设置
使用send_file结果将零字节文件发送到浏览器
filepath = Rails.root.join('export',"#{filename}.csv") if File.exists?(filepath) send_file filepath,:type => 'text/csv' end
另一个缺点(除了绑定一个rails进程太久),当数据流由rails进程处理时,响应似乎没有发送内容长度头.所以用户不知道他们下载的文件有多大,也不知道需要多长时间(可用性问题).
我可以通过确保mod_sendfile正确地包含在我的apache配置中并加载到我的apache配置中,这样就可以得到它(这将取决于你的apache安装等等):
LoadModule xsendfile_module /usr/lib64/httpd/modules/mod_xsendfile.so ... # enable mod_x_sendfile for offloading zip file downloads from rails XSendFile on XSendFilePath /
以上是大佬教程为你收集整理的ruby-on-rails – Rails 3,apache和passenger,send_file发送零字节文件全部内容,希望文章能够帮你解决ruby-on-rails – Rails 3,apache和passenger,send_file发送零字节文件所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。