From 39313bd726656a9f6950a450e66b5d54b7e03533 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 6 Feb 2020 21:24:45 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=86=E9=A2=91=E6=92=AD=E6=94=BE=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/attachments_controller.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index e0dd71467..0bfe9f124 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -17,9 +17,12 @@ class AttachmentsController < ApplicationController redirect_to @file.cloud_url and return end - pdf_attachment = params[:disposition] || "attachment" - if pdf_attachment == "inline" + type_attachment = params[:disposition] || "attachment" + if type_attachment == "inline" send_file absolute_path(local_path(@file)),filename: @file.title, disposition: 'inline',type: 'application/pdf' + elsif type_attachment == "MP4" + response.header["Accept-Ranges"] = "bytes" + send_file absolute_path(local_path(@file)),filename: @file.title, disposition: 'inline',type: @file.content_type.presence || 'application/octet-stream' else send_file(absolute_path(local_path(@file)), filename: @file.title,stream:false, type: @file.content_type.presence || 'application/octet-stream') end