Upload files with the correct extension
This commit is contained in:
parent
365ead6b5f
commit
f4cfae8581
1 changed files with 2 additions and 2 deletions
|
@ -28,10 +28,10 @@ namespace :cloudstorage do
|
||||||
content = (c == Procedure)? entry.logo : entry.content
|
content = (c == Procedure)? entry.logo : entry.content
|
||||||
unless content.current_path.nil? || File.exist?(File.dirname(content.current_path) + '/uploaded')
|
unless content.current_path.nil? || File.exist?(File.dirname(content.current_path) + '/uploaded')
|
||||||
secure_token = SecureRandom.uuid
|
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}"
|
puts "Uploading #{content.current_path}"
|
||||||
begin
|
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)) }
|
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)
|
entry.update_column(c == Procedure ? :logo : :content, filename)
|
||||||
rescue Errno::ENOENT
|
rescue Errno::ENOENT
|
||||||
|
|
Loading…
Reference in a new issue