exceptionfactory commented on code in PR #6193:
URL: https://github.com/apache/nifi/pull/6193#discussion_r942881754
##########
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/PutEmail.java:
##########
@@ -245,6 +245,17 @@ public class PutEmail extends AbstractProcessor {
.allowableValues("true", "false")
.defaultValue("false")
.build();
+ public static final PropertyDescriptor INPUT_CHARACTER_SET = new
PropertyDescriptor.Builder()
+ .name("input-character-set")
+ .displayName("Input Character Set")
+ .description("Specifies the character set of the FlowFile contents
"
+ + "for reading input FlowFile contents to generate the
message body "
+ + "or as an attachment to the message. "
+ + "If not set, UTF-8 will be the default value.")
+ .required(true)
+ .addValidator(StandardValidators.CHARACTER_SET_VALIDATOR)
+ .defaultValue(StandardCharsets.UTF_8.name())
Review Comment:
This should probably be `StandardCharsets.UTF_8.toString()` instead of
`UTF_8.name()`.
##########
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/PutEmail.java:
##########
@@ -386,17 +398,26 @@ public void onTrigger(final ProcessContext context, final
ProcessSession session
}
this.setMessageHeader("X-Mailer",
context.getProperty(HEADER_XMAILER).evaluateAttributeExpressions(flowFile).getValue(),
message);
message.setSubject(context.getProperty(SUBJECT).evaluateAttributeExpressions(flowFile).getValue());
+ message.setSentDate(new Date());
final String messageText = getMessage(flowFile, context, session);
-
final String contentType =
context.getProperty(CONTENT_TYPE).evaluateAttributeExpressions(flowFile).getValue();
- message.setContent(messageText, contentType);
- message.setSentDate(new Date());
+ final Charset charset = getCharset(context);
+ final String charsetName = MimeUtility.mimeCharset(charset.name());
+ final DataHandler messageDataHandler = new DataHandler(
+ new ByteArrayDataSource(
+ Base64.encodeBase64(messageText.getBytes(charset)),
+ contentType + String.format("; charset=\"%s\"",
charsetName)
+ )
+ );
+
+ final MimeMultipart multipart = new MimeMultipart();
+ final MimeBodyPart mimeText = new PreencodedMimeBodyPart("base64");
+ mimeText.setDataHandler(messageDataHandler);
+ mimeText.setHeader("Content-Transfer-Encoding", "base64");
+ multipart.addBodyPart(mimeText);
Review Comment:
This approach changes the message format to always use multipart formatting,
which does not seem the like the ideal solution.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]