diff --git a/lib/api/helpers/attachment_renderer.rb b/lib/api/helpers/attachment_renderer.rb index 5ae693317f..49fbe4d4ff 100644 --- a/lib/api/helpers/attachment_renderer.rb +++ b/lib/api/helpers/attachment_renderer.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 diff --git a/spec/requests/api/v3/attachments/attachment_resource_shared_examples.rb b/spec/requests/api/v3/attachments/attachment_resource_shared_examples.rb index ccace9fe91..a67429ddf8 100644 --- a/spec/requests/api/v3/attachments/attachment_resource_shared_examples.rb +++ b/spec/requests/api/v3/attachments/attachment_resource_shared_examples.rb @@ -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