12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/gitlab/email/attachment_uploader.rb', line 12
def execute(upload_parent:, uploader_class:, author: nil)
attachments = []
filter_signature_attachments(message).each do |attachment|
tmp = Tempfile.new("gitlab-email-attachment")
begin
content = attachment.body.decoded
File.open(tmp.path, "w+b") { |f| f.write content }
sanitize_exif_if_needed(content, tmp.path)
file = {
tempfile: tmp,
filename: attachment.filename,
content_type: attachment.content_type
}
uploader = UploadService.new(
upload_parent,
file,
uploader_class,
uploaded_by_user_id: author&.id
).execute
attachments << uploader.to_h if uploader
ensure
tmp.close!
end
end
attachments
end
|