Skip to content

Commit

Permalink
Merge pull request #888 from jrieger/send_file
Browse files Browse the repository at this point in the history
Use `send_file` instead of `send_data`
  • Loading branch information
tvdeyen committed Oct 6, 2015
2 parents b6c0c07 + 814b0fe commit a6fb572
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/controllers/alchemy/admin/attachments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
8 changes: 4 additions & 4 deletions app/controllers/alchemy/attachments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/admin/attachments_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a6fb572

Please sign in to comment.