Swoosh.Attachment.new
You're seeing just the function
new
, go back to Swoosh.Attachment module for more information.
Specs
new(binary() | struct() | {:data, binary()}, Keyword.t() | map()) :: %Swoosh.Attachment{ content_type: term(), data: term(), filename: term(), headers: term(), path: term(), type: term() }
Creates a new Attachment
Examples:
Attachment.new("/path/to/attachment.png")
Attachment.new("/path/to/attachment.png", filename: "image.png")
Attachment.new("/path/to/attachment.png", filename: "image.png", content_type: "image/png")
Attachment.new(params["file"]) # Where params["file"] is a %Plug.Upload
Attachment.new({:data, File.read!("/path/to/attachment.png")}, filename: "image.png", content_type: "image/png")
Examples with inline-attachments:
Attachment.new("/path/to/attachment.png", type: :inline)
Attachment.new("/path/to/attachment.png", filename: "image.png", type: :inline)
Attachment.new("/path/to/attachment.png", filename: "image.png", content_type: "image/png", type: :inline)
Attachment.new(params["file"], type: :inline) # Where params["file"] is a %Plug.Upload
Attachment.new({:data, File.read!("/path/to/attachment.png")}, filename: "image.png", content_type: "image/png", type: :inline)
Inline attachments by default use their filename (or basename of the path if filename is not specified) as cid, in relevant adapters.
Attachment.new("/data/file.png", type: :inline)
Gives you something like this:
<img src="cid:file.png">