我使用 Helicon Zoo 在 Windows Server 2008 机器上设置了一个 rails 应用程序。
我的问题是下载 400MB 以上的文件。
在我的 rails 应用程序中,我使用以下内容将文件发送到客户端:
应用程序/控制器/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
我在 production.rb 文件中注释掉了config.action_dispatch.x_sendfile_header,因为我没有使用 Apache 或 Nginx。
这适用于服务器上低于 ~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,但我害怕搞砸已经(几乎)工作的应用程序。
有谁知道如何解决这个问题?