-
Notifications
You must be signed in to change notification settings - Fork 342
Closed
Labels
Milestone
Description
I propose that we change the current Attachement
struct before releasing version 1.0.
Why?
At the moment an attachment struct looks like this:
defstruct filename: nil, content_type: nil, path: nil
This only allows uploads from the file system, not dynamically generated contents.
An use case for generated contents would be .ics
files. You want to append a
generated .ics
file for adding an event to the user's calendar.
Furthermore every adapter has to implement the correct encoding - this is redundant.
Here's an example I found from a patch for the bamboo_stmp adapter:
defp add_attachment_body(body, attachment) do
file = File.read!(attachment)
"#{body}\r\n#{Base.encode64(file)}\r\n"
end
Proposal:
We change the struct definition to:
defstruct filename: nil, content_type: nil, data: nil
We could:
- Split the
new
function intonew_from_data
andnew_from_attachment
- Use pattern matching in the
new
function
The new new method does the job of file reading and encoding.
What do you think?
gitviola, randycoulman and SergeyKorochansky