MCPcopy Create free account
hub / github.com/Mnexa-AI/e2a / Attachments

Function Attachments

internal/mailparse/attachments.go:34–50  ·  view source on GitHub ↗

Attachments walks the MIME tree of a raw RFC 5322 message and returns its attachment parts in stable document order (depth-first, as they appear in the wire bytes). Index N from this function is the SAME index used by AttachmentAt and by the message read view — it is the authoritative attachment ind

(raw []byte)

Source from the content-addressed store, hash-verified

32// On a parse failure or a non-multipart message with no attachment part, returns
33// an empty slice (never nil-panics).
34func Attachments(raw []byte) []Attachment {
35 msg, err := mail.ReadMessage(bytes.NewReader(raw))
36 if err != nil {
37 return nil
38 }
39 var out []Attachment
40 collectAttachments(
41 msg.Header.Get("Content-Type"),
42 msg.Header.Get("Content-Transfer-Encoding"),
43 msg.Header.Get("Content-Disposition"),
44 "", // top-level has no part filename
45 msg.Body,
46 0,
47 &out,
48 )
49 return out
50}
51
52// AttachmentAt returns the attachment at the 0-based index, or false if out of
53// range. It re-walks the message (the caller holds the raw bytes); attachments

Calls 2

collectAttachmentsFunction · 0.85
GetMethod · 0.65