Class: Gitlab::Email::AttachmentUploader
- Inherits:
-
Object
- Object
- Gitlab::Email::AttachmentUploader
- Defined in:
- lib/gitlab/email/attachment_uploader.rb
Instance Attribute Summary collapse
-
#message ⇒ Object
Returns the value of attribute message.
Instance Method Summary collapse
- #execute(upload_parent:, uploader_class:, author: nil) ⇒ Object
-
#initialize(message) ⇒ AttachmentUploader
constructor
A new instance of AttachmentUploader.
Constructor Details
#initialize(message) ⇒ AttachmentUploader
Returns a new instance of AttachmentUploader.
8 9 10 |
# File 'lib/gitlab/email/attachment_uploader.rb', line 8 def initialize() @message = end |
Instance Attribute Details
#message ⇒ Object
Returns the value of attribute message.
6 7 8 |
# File 'lib/gitlab/email/attachment_uploader.rb', line 6 def @message end |
Instance Method Details
#execute(upload_parent:, uploader_class:, author: nil) ⇒ Object
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) = [] ().each do || tmp = Tempfile.new("gitlab-email-attachment") begin content = .body.decoded File.open(tmp.path, "w+b") { |f| f.write content } sanitize_exif_if_needed(content, tmp.path) file = { tempfile: tmp, filename: .filename, content_type: .content_type } uploader = UploadService.new( upload_parent, file, uploader_class, uploaded_by_user_id: &.id ).execute << uploader.to_h if uploader ensure tmp.close! end end end |