diff --git a/app/controllers/code_ocean/files_controller.rb b/app/controllers/code_ocean/files_controller.rb index 34567723..9ceed9cc 100644 --- a/app/controllers/code_ocean/files_controller.rb +++ b/app/controllers/code_ocean/files_controller.rb @@ -23,7 +23,7 @@ module CodeOcean raise Pundit::NotAuthorizedError if @embed_options[:disable_download] || @file.filepath != params[:filename] real_location = Pathname(@file.native_file.current_path).realpath - send_file(real_location, type: @file.native_file.content_type, filename: @file.name_with_extension, disposition: 'attachment') + send_file(real_location, type: 'application/octet-stream', filename: @file.name_with_extension, disposition: 'attachment') end def render_protected_upload diff --git a/app/controllers/submissions_controller.rb b/app/controllers/submissions_controller.rb index 229aec47..bb9e49b7 100644 --- a/app/controllers/submissions_controller.rb +++ b/app/controllers/submissions_controller.rb @@ -57,7 +57,7 @@ class SubmissionsController < ApplicationController end zip_data = stringio.string response.set_header('Content-Length', zip_data.size) - send_data(zip_data, filename: "#{@submission.exercise.title.tr(' ', '_')}.zip") + send_data(zip_data, type: 'application/octet-stream', filename: "#{@submission.exercise.title.tr(' ', '_')}.zip", disposition: 'attachment') end def download_file @@ -67,7 +67,7 @@ class SubmissionsController < ApplicationController redirect_to protected_upload_path(id: @file.id, filename: @file.filepath) else response.set_header('Content-Length', @file.size) - send_data(@file.content, filename: @file.name_with_extension, disposition: 'attachment') + send_data(@file.content, type: 'application/octet-stream', filename: @file.name_with_extension, disposition: 'attachment') end end diff --git a/spec/controllers/code_ocean/files_controller_spec.rb b/spec/controllers/code_ocean/files_controller_spec.rb index 476b72bc..41f042d9 100644 --- a/spec/controllers/code_ocean/files_controller_spec.rb +++ b/spec/controllers/code_ocean/files_controller_spec.rb @@ -17,7 +17,7 @@ describe CodeOcean::FilesController do let(:file) { submission.collect_files.detect {|file| file.file_type.file_extension == '.mp4' } } expect_assigns(file: :file) - expect_content_type('video/mp4') + expect_content_type('application/octet-stream') expect_http_status(:ok) it 'sets the correct filename' do diff --git a/spec/controllers/submissions_controller_spec.rb b/spec/controllers/submissions_controller_spec.rb index afdaa088..ed33a37f 100644 --- a/spec/controllers/submissions_controller_spec.rb +++ b/spec/controllers/submissions_controller_spec.rb @@ -85,7 +85,7 @@ describe SubmissionsController do expect_assigns(file: :file) expect_assigns(submission: :submission) - expect_content_type('text/javascript') + expect_content_type('application/octet-stream') expect_http_status(:ok) it 'sets the correct filename' do