【发布时间】:2014-04-18 23:09:21
【问题描述】:
我使用 Helicon Zoo 在 Windows Server 2008 机器上设置了一个 rails 应用程序。
我的问题是下载超过 400MB 的文件。
在我的 rails 应用程序中,我使用以下内容将文件发送到客户端:
app/controllers/hosted_files_controller.rb
class HostedFilesController < ApplicationController
before_filter :authenticate_user!
around_filter :catch_not_foun
def download
@footprint = UserAbility.new(current_user).footprints.find(params[:id])
send_file path
end
private
def path
if @footprint.subpath?
@path = "#{HOSTED_FILES_PATH}\\#{@footprint.subpath}\\#{@footprint.filename}"
else
@path = "#{HOSTED_FILES_PATH}\\#{@footprint.filename}"
end
end
def catch_not_found
yield
rescue ActiveRecord::RecordNotFound
recover_and_log "We couldn't find that record.", "No record found using the id (#{params[:id]})"
rescue ActionController::MissingFile
recover_and_log "We couldn't find the file on our server.", "The file was not found at the following path: #{@path}"
end
def recover_and_log (displayed, logged)
logger.info "!!! Error: #{logged}"
redirect_to root_url, alert: displayed
end
end
由于我没有使用 Apache 或 Nginx,因此我在 production.rb 文件中已将 config.action_dispatch.x_sendfile_header 注释掉。
这适用于服务器上低于 ~400MB 的所有文件。超过它之后,我从 Helicon Zoo 收到 500 内部服务器错误,内容如下:
Helicon Zoo module has caught up an error. Please see the details below.
Worker Status
The process was created
Windows error
The pipe has been ended. (ERROR CODE: 109)
Internal module error
message: ZooApplication backend read Error.
type: ZooException
file: Jobs\JobBase.cpp
line: 566
version: 3.1.98.508
STDERR
Empty stderr
有人知道发生了什么吗?我很茫然。
我试过了:
- 增加 send_file 上的 buffer_size(无效)
- 在 IIS 中为应用程序池设置内存(无效)
- 将 x_sendfile_header 更改为 X-Sendfile 和 X-Accel-Redirect(无效)
我正在考虑尝试在 Windows Server 上安装 Apache 并使用 x_sendfile_header 卸载将文件发送到 Apache,但我担心会弄乱已经(几乎)工作的应用程序。
有没有人知道如何解决这个问题?
【问题讨论】:
-
这不是 ruby on rails 的问题。这是您的应用程序/网络服务器的问题。因为有数据发送限制。就像在 nginx 中一样,您可以指定客户端最大正文大小。
标签: ruby-on-rails ruby iis download heliconzoo