From 2110bdb13ebff63e23b34908d5eadc528fa74cab Mon Sep 17 00:00:00 2001 From: Jeff Ohrstrom Date: Thu, 8 Aug 2024 09:36:35 -0400 Subject: [PATCH] just supply zipname and have rails format it (#3694) Let Rails set content-type and content-disposition headers. --- apps/dashboard/app/controllers/files_controller.rb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/apps/dashboard/app/controllers/files_controller.rb b/apps/dashboard/app/controllers/files_controller.rb index 3875b73321..0e297551fa 100644 --- a/apps/dashboard/app/controllers/files_controller.rb +++ b/apps/dashboard/app/controllers/files_controller.rb @@ -52,9 +52,7 @@ def fs end if can_download - zipname = "#{@path.basename.to_s.gsub('"', '\"')}.zip" - response.set_header 'Content-Disposition', "attachment; filename=\"#{zipname}\"" - response.set_header 'Content-Type', 'application/zip' + zipname = "#{@path.basename}.zip" response.set_header 'Last-Modified', Time.now.httpdate response.sending_file = true response.cache_control[:public] ||= false @@ -62,7 +60,7 @@ def fs zip_headers = ZipKit::OutputEnumerator.new.streaming_http_headers response.headers.merge!(zip_headers) - send_stream(filename: zipname) do |stream| + send_stream(filename: zipname, disposition: 'attachment', type: :zip) do |stream| ZipKit::Streamer.open(stream) do |zip| @path.files_to_zip.each do |file| next unless File.readable?(file.realpath)