A workaround for missing ZIP file while emailing
This commit is contained in:
parent
30edb86ed4
commit
d6b3c9e94d
@ -185,7 +185,11 @@ class DmsfController < ApplicationController
|
||||
flash[:error] = l(:error_email_to_must_be_entered)
|
||||
else
|
||||
DmsfMailer.deliver_send_documents(@project, params[:email].permit!, User.current)
|
||||
File.delete(params[:email][:zipped_content])
|
||||
if(File.exist?(params[:email][:zipped_content]))
|
||||
File.delete(params[:email][:zipped_content])
|
||||
else
|
||||
flash[:error] = l(:header_minimum_filesize)
|
||||
end
|
||||
flash[:notice] = l(:notice_email_sent, params[:email][:to])
|
||||
end
|
||||
redirect_to dmsf_folder_path(id: @project, folder_id: @folder)
|
||||
|
||||
@ -84,8 +84,12 @@ class DmsfMailer < Mailer
|
||||
@files = email_params[:files]
|
||||
@author = author
|
||||
unless @links_only
|
||||
zipped_content_data = open(email_params[:zipped_content], 'rb') { |io| io.read }
|
||||
attachments['Documents.zip'] = { content_type: 'application/zip', content: zipped_content_data }
|
||||
if File.exist?(email_params[:zipped_content])
|
||||
zipped_content_data = open(email_params[:zipped_content], 'rb') { |io| io.read }
|
||||
attachments['Documents.zip'] = { content_type: 'application/zip', content: zipped_content_data }
|
||||
else
|
||||
Rails.logger.error "Cannot attach #{email_params[:zipped_content]}, it doesn't exist."
|
||||
end
|
||||
end
|
||||
mail to: email_params[:to], cc: email_params[:cc], subject: email_params[:subject], 'From' => email_params[:from],
|
||||
'Reply-To' => email_params[:reply_to]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user