別の修正版 - 私は、バイナリコンテンツとしてzipファイルをダウンロードしようとしていた、これは私のために働いていたものです -
def byte_range_response (request, response, content)
file_begin = 0
file_size = content.bytesize
file_end = file_size - 1
status_code = '206 Partial Content'
match = request.headers['range'].match(/bytes=(\d+)-(\d*)/)
if match
file_begin = match[1]
file_end = match[2] if match[2] && !match[2].empty?
end
content_length = file_end.to_i - file_begin.to_i + 1
response.header['Content-Range'] = 'bytes ' + file_begin.to_s + '-' + file_end.to_s + '/' + file_size.to_s
response.header['Content-Length'] = content_length.to_s
response.header['Cache-Control'] = 'public, must-revalidate, max-age=0'
response.header['Pragma'] = 'no-cache'
response.header['Accept-Ranges']= 'bytes'
response.header['Content-Transfer-Encoding'] = 'binary'
send_data get_partial_content(content, content_length, file_begin.to_i), type: 'application/octet-stream', status: status_code
end
def get_partial_content(content, content_length, offset)
test_file = Tempfile.new(['test-file', '.zip'])
test_file.puts(content)
partial_content = IO.binread(test_file.path, content_length, offset)
test_file.close
test_file.unlink
partial_content
end
Webサーバを使用していますか? – NARKOZ
apache 2 with passenger modul – Markus
https://gist.github.com/mikhailov/3174601を試してみましたか? – Anatoly