[31205] Fix attachment disposition for local files

This got first changed in https://github.com/opf/openproject/pull/7456
And then disposition for local removed in a33016a24676e9ae86c03be6241c811b57116dc7#diff-7b0581da1680146a96496be759fc3240

https://community.openproject.com/wp/31205k
pull/7736/head
Oliver Günther 5 years ago
parent e4a686f389
commit 50828e930a
No known key found for this signature in database
GPG Key ID: A3A8BDAD7C0C552C
  1. 2
      lib/api/helpers/attachment_renderer.rb
  2. 4
      spec/requests/api/v3/attachments/attachment_resource_shared_examples.rb

@ -43,7 +43,7 @@ module API
redirect attachment.external_url.to_s
else
content_type attachment.content_type
header['Content-Disposition'] = attachment.content_disposition
header['Content-Disposition'] = "#{attachment.content_disposition}; filename=#{attachment.filename}"
env['api.format'] = :binary
attachment.diskfile.read
end

@ -287,14 +287,14 @@ shared_examples 'an APIv3 attachment resource', type: :request, content_type: :j
context 'for a local text file' do
it_behaves_like 'for a local file' do
let(:mock_file) { FileHelpers.mock_uploaded_file name: 'foobar.txt' }
let(:content_disposition) { "inline" }
let(:content_disposition) { "inline; filename=foobar.txt" }
end
end
context 'for a local binary file' do
it_behaves_like 'for a local file' do
let(:mock_file) { FileHelpers.mock_uploaded_file name: 'foobar.dat', content_type: "application/octet-stream" }
let(:content_disposition) { "attachment" }
let(:content_disposition) { "attachment; filename=foobar.dat" }
end
end

Loading…
Cancel
Save