ProcessAttachmentWithMetadata is like [ProcessAttachment] but also returns the [ImageResizeResult] when the attachment was an image that went through [ResizeImage]. The metadata is nil for non-image attachments. Callers that need to emit a dimension note (for model coordinate-mapping) should use th
(part MessagePart)
| 60 | // should use this variant and call [FormatDimensionNote] on the returned |
| 61 | // metadata. |
| 62 | func ProcessAttachmentWithMetadata(part MessagePart) (Document, *ImageResizeResult, error) { |
| 63 | switch part.Type { |
| 64 | case MessagePartTypeFile: |
| 65 | return processFilePart(part) |
| 66 | case MessagePartTypeImageURL: |
| 67 | return processImageURLPart(part) |
| 68 | case MessagePartTypeDocument: |
| 69 | return processDocumentPart(part) |
| 70 | default: |
| 71 | return Document{}, nil, fmt.Errorf("ProcessAttachment: unsupported part type %q", part.Type) |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | // processFilePart handles MessagePartTypeFile: reads from disk, detects MIME, |
| 76 | // routes to text-inline or binary-inline as appropriate. |
no test coverage detected