fix auto open pdf file

This commit is contained in:
Harry Bomrah 2025-04-21 11:38:47 +00:00
parent 613a342e01
commit 65c461a9b4
1 changed files with 9 additions and 9 deletions

View File

@ -223,9 +223,9 @@ class ArchivesController < ApplicationController
@path = file.file.file.file rescue "" @path = file.file.file.file rescue ""
@filename = File.basename(@path) @filename = File.basename(@path)
@ext = @filename.split(".").last @ext = @filename.split(".").last
if @ext == "png" || @ext == "jpg" || @ext == "bmp" || @ext == "pdf" #if @ext == "png" || @ext == "jpg" || @ext == "bmp" || @ext == "pdf"
render "download_file",:layout=>false #render "download_file",:layout=>false
else #else
if (current_site.accessibility_mode rescue false) if (current_site.accessibility_mode rescue false)
render "redirect_to_file",:layout=>false render "redirect_to_file",:layout=>false
else else
@ -233,7 +233,7 @@ class ArchivesController < ApplicationController
@escaped_file_name = user_agent.match(/(msie|trident)/) ? CGI::escape(@filename) : @filename @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) send_file(@path, :type=>"application/octet-stream", :filename => @escaped_file_name, :x_sendfile=> true)
end end
end #end
rescue rescue
redirect_to @url redirect_to @url
end end