From e8dcb166756861f64edd9f5a487d60eb1b804bcd Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Sat, 17 Aug 2019 13:56:14 +0800 Subject: [PATCH] =?UTF-8?q?pdf=20=E9=A2=84=E8=A7=88=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/attachments_controller.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index dde7828c5..7617270a8 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -18,7 +18,8 @@ class AttachmentsController < ApplicationController pdf_attachment = params[:disposition] || "attachment" if pdf_attachment == "inline" - render pdf: absolute_path(local_path(@file)), filename: @file.filename, disposition: 'inline', type: @file.content_type.presence || 'application/octet-stream' + send_data absolute_path(local_path(@file)),filename: @file.filename, disposition: 'inline',type: 'application/pdf' + # 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