pdf的预览添加disposition

dev_winse
SylorHuang 6 years ago
parent b9de46e875
commit 8af97d5655

@ -17,8 +17,11 @@ class AttachmentsController < ApplicationController
end
pdf_attachment = params[:disposition] || "attachment"
send_file(absolute_path(local_path(@file)), filename: @file.filename,disposition: pdf_attachment, type: @file.content_type.presence || 'application/octet-stream')
if pdf_attachment == "inline"
render pdf: absolute_path(local_path(@file)), filename: @file.filename, disposition: 'inline', type: @file.content_type.presence || 'application/octet-stream'
else
send_file(absolute_path(local_path(@file)), filename: @file.filename,stream:false, type: @file.content_type.presence || 'application/octet-stream')
end
update_downloads(@file)
end

Loading…
Cancel
Save