fix auto open pdf file 2026

This commit is contained in:
chiu 2026-02-10 11:25:02 +00:00
parent 07e361d4ae
commit ee713e442d
1 changed files with 5 additions and 1 deletions

View File

@ -231,7 +231,11 @@ class ArchivesController < ApplicationController
else
user_agent = request.user_agent.downcase
@escaped_file_name = user_agent.match(/(msie|trident)/) ? CGI::escape(@filename) : @filename
send_file(@path, :type=>"application/octet-stream", :filename => @escaped_file_name, :x_sendfile=> true)
if @ext == "pdf"
send_file(@path, :type => "application/pdf", :disposition => "inline", :filename => @escaped_file_name, :x_sendfile => true)
else
send_file(@path, :type => "application/octet-stream", :filename => @escaped_file_name, :x_sendfile => true)
end
end
#end
rescue