nylas / nylas-ruby

Ruby bindings for the Nylas Platform APIs
https://nylas.com/docs
MIT License
101 stars 130 forks source link

Support Custom content_id for Attachments in multipart/form-data #505

Open KJambo opened 6 days ago

KJambo commented 6 days ago

Currently, the Nylas Ruby SDK does not allow users to set a custom content_id for attachments when sending emails as multipart/form-data. This limitation makes it difficult to use inline attachments, such as embedding images directly in the email body (e.g., <img src="cid:custom_content_id" />).

In the current implementation, the SDK automatically assigns attachment names like file0, file1, etc., when constructing the form request(source). While these names are internally treated as content_id by the Nylas API and can technically be used (e.g., <img src="cid:file0" />), users have no control over these identifiers. This lack of customization limits the flexibility and usability of inline attachments.

I would like the SDK to support user-defined content_id for attachments. Specifically:

KJambo commented 5 days ago

It seems that the method at file_utils.rb#L90 changes the attachment handling between JSON and form-based approaches depending on the attachment size. As a result, the way content_id is referenced also changes. This behavior seems inconsistent and might be a bug