Added attachment size check.

This commit is contained in:
Martin Edenhofer 2015-04-07 01:34:47 +02:00
parent 1298f15b62
commit acbe704c3b

View file

@ -78,13 +78,12 @@ returns
# lookup attachments # lookup attachments
article.attachments.each {|attachment| article.attachments.each {|attachment|
if !attributes['attachments'] if !article_attributes['attachments']
attributes['attachments'] = [] article_attributes['attachments'] = []
end end
# check file size # check file size
if true if attachment.content && attachment.content.size / 1024 <= attachment_max_size_in_mb * 1024
# if attachment.content && attachment.content.size / 1024 / 1024 <= attachment_max_size_in_mb
# check ignored files # check ignored files
if attachment.filename if attachment.filename
@ -92,10 +91,10 @@ returns
filename_extention.gsub!(/^.*(\..+?)$/, "\\1") filename_extention.gsub!(/^.*(\..+?)$/, "\\1")
if !attachments_ignore.include?( filename_extention.downcase ) if !attachments_ignore.include?( filename_extention.downcase )
data = { data = {
'_name' => attachment.filename, '_name' => attachment.filename,
'content' => Base64.encode64( attachment.content ) '_content' => Base64.encode64( attachment.content )
} }
attributes['attachments'].push data article_attributes['attachments'].push data
end end
end end
end end