From f4cfae85817eef8d55129b7485c7ebac03d39f41 Mon Sep 17 00:00:00 2001 From: Guillaume Lazzara Date: Mon, 4 Jul 2016 18:00:15 +0200 Subject: [PATCH] Upload files with the correct extension --- lib/tasks/cloud_storage.rake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/tasks/cloud_storage.rake b/lib/tasks/cloud_storage.rake index 379fa081f..a04c81811 100644 --- a/lib/tasks/cloud_storage.rake +++ b/lib/tasks/cloud_storage.rake @@ -28,10 +28,10 @@ namespace :cloudstorage do content = (c == Procedure)? entry.logo : entry.content unless content.current_path.nil? || File.exist?(File.dirname(content.current_path) + '/uploaded') secure_token = SecureRandom.uuid - filename = "#{entry.class.to_s.underscore}-#{secure_token}.pdf" + filename = "#{entry.class.to_s.underscore}-#{secure_token}#{File.extname(content.current_path)}" puts "Uploading #{content.current_path}" begin - @cont.create_object(filename, { content_type: "application/pdf"}, File.open(content.current_path)) + @cont.create_object(filename, {}, File.open(content.current_path)) File.open(File.dirname(content.current_path) + '/uploaded', "w+"){ |f| f.write(File.basename(content.current_path)) } entry.update_column(c == Procedure ? :logo : :content, filename) rescue Errno::ENOENT