Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
X-Sendfile middleware for JRuby-Rack 1.0.8 or greater
class JRubyRackXSendfile
def initialize(app)
@app = app
end
def call(env)
result, headers, body = @app.call(env)
if headers['X-Sendfile']
[result, headers, File.new(headers.delete('X-Sendfile'))]
else
[result, headers, body]
end
end
end
@mindscratch

...make sure the controller sets the header when sending a file so this middleware picks it up.

@nicksieger
Owner

To clarify, for example:

module ApplicationHelper
  def set_sendfile_header(path_to_file)
    request.headers['X-Sendfile'] = path_to_file.to_s
  end
end
class MyController < ApplicationController
  def download
    set_sendfile_header params[:file]
  end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.