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 1/5] =?UTF-8?q?=E8=A7=86=E9=A2=91=E6=92=AD=E6=94=BE?= =?UTF-8?q?=E9=97=AE=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 From ad0e3cb128d23f567ac524402b35bf2cb739acce Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 6 Feb 2020 21:37:29 +0800 Subject: [PATCH 2/5] 1 --- app/controllers/attachments_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index 0bfe9f124..eb962ad2e 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -22,7 +22,7 @@ class AttachmentsController < ApplicationController 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' + send_file absolute_path(local_path(@file)),filename: @file.title, disposition: 'inline',type: @file.content_type.presence || 'application/octet-stream', status: 206 else send_file(absolute_path(local_path(@file)), filename: @file.title,stream:false, type: @file.content_type.presence || 'application/octet-stream') end From e7de4550cf202b4a9659bcd34d70674d8ed545ae Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 6 Feb 2020 21:41:26 +0800 Subject: [PATCH 3/5] 1 --- app/controllers/attachments_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index eb962ad2e..107932cd8 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -22,7 +22,7 @@ class AttachmentsController < ApplicationController 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', status: 206 + send_file absolute_path(local_path(@file)),filename: @file.title,type: @file.content_type.presence || 'application/octet-stream', status: 206 else send_file(absolute_path(local_path(@file)), filename: @file.title,stream:false, type: @file.content_type.presence || 'application/octet-stream') end From f2cd502b2f10def116749114e2accc62b8b8026e Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 6 Feb 2020 21:48:18 +0800 Subject: [PATCH 4/5] 1 --- app/controllers/attachments_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index 107932cd8..a3352aaca 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -22,7 +22,7 @@ class AttachmentsController < ApplicationController 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,type: @file.content_type.presence || 'application/octet-stream', status: 206 + send_file absolute_path(local_path(@file)),filename: @file.title,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 From 1e834e18aae81d6de26b1f65b882ccbeb3ced755 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 6 Feb 2020 21:55:57 +0800 Subject: [PATCH 5/5] 1 --- app/controllers/attachments_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index a3352aaca..184d63120 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -22,7 +22,7 @@ class AttachmentsController < ApplicationController 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,type: @file.content_type.presence || 'application/octet-stream' + send_file absolute_path(local_path(@file)),filename: @file.title,type: @file.content_type.presence || 'application/octet-stream', x_sendfile: true else send_file(absolute_path(local_path(@file)), filename: @file.title,stream:false, type: @file.content_type.presence || 'application/octet-stream') end