diff --git a/app/controllers/alchemy/admin/attachments_controller.rb b/app/controllers/alchemy/admin/attachments_controller.rb index 9b5b9aa490..02b6bb3b9c 100644 --- a/app/controllers/alchemy/admin/attachments_controller.rb +++ b/app/controllers/alchemy/admin/attachments_controller.rb @@ -75,7 +75,7 @@ def destroy def download @attachment = Attachment.find(params[:id]) - send_data @attachment.file.data, { + send_file @attachment.file.path, { filename: @attachment.file_name, type: @attachment.file_mime_type } diff --git a/app/controllers/alchemy/attachments_controller.rb b/app/controllers/alchemy/attachments_controller.rb index 84316e1a06..dcd6cd807e 100644 --- a/app/controllers/alchemy/attachments_controller.rb +++ b/app/controllers/alchemy/attachments_controller.rb @@ -5,8 +5,8 @@ class AttachmentsController < BaseController # sends file inline. i.e. for viewing pdfs/movies in browser def show - send_data( - @attachment.file.data, + send_file( + @attachment.file.path, { filename: @attachment.file_name, type: @attachment.file_mime_type, @@ -17,8 +17,8 @@ def show # sends file as attachment. aka download def download - send_data( - @attachment.file.data, { + send_file( + @attachment.file.path, { filename: @attachment.file_name, type: @attachment.file_mime_type } diff --git a/spec/controllers/admin/attachments_controller_spec.rb b/spec/controllers/admin/attachments_controller_spec.rb index 9854f0d5f5..d3904d2955 100644 --- a/spec/controllers/admin/attachments_controller_spec.rb +++ b/spec/controllers/admin/attachments_controller_spec.rb @@ -203,7 +203,7 @@ module Alchemy end it "should send the data to the browser" do - expect(controller).to receive(:send_data) + expect(controller).to receive(:send_file) alchemy_get :download, id: attachment.id end end