Skip to content

Commit ba8588b

Browse files
committed
Revert "Revert "support sendemail about md file.""
This reverts commit 66b01f0.
1 parent 66b01f0 commit ba8588b

File tree

3 files changed

+42
-3
lines changed

3 files changed

+42
-3
lines changed

dss-appconn/appconns/dss-sendemail-appconn/sendemail-appconn-core/src/main/scala/com/webank/wedatasphere/dss/appconn/sendemail/conf/SendEmailAppConnConfiguration.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,6 @@ object SendEmailAppConnConfiguration {
5252
val EMAIL_ENTITY_CLASSES = CommonVars("wds.dss.appconn.email.hook.entity.classes",
5353
"com.webank.wedatasphere.dss.appconn.sendemail.hook.entity.newvisualis.NewVisualisEmailInfo," +
5454
"com.webank.wedatasphere.dss.appconn.sendemail.hook.entity.visualis.VisualisEmailInfo," +
55-
"com.webank.wedatasphere.dss.appconn.sendemail.hook.entity.visualis.MetaBaseEmailInfo")
55+
"com.webank.wedatasphere.dss.appconn.sendemail.hook.entity.visualis.MetaBaseEmailInfo," +
56+
"com.webank.wedatasphere.dss.appconn.sendemail.hook.entity.mlss.MlssEmailInfo")
5657
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Copyright 2019 WeBank
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
*
15+
*/
16+
17+
package com.webank.wedatasphere.dss.appconn.sendemail.email.domain
18+
19+
import java.io.File
20+
21+
class MdAttachment(name: String, b64: String) extends Attachment {
22+
23+
override def getName: String = name
24+
25+
override def getBase64Str: String = b64
26+
27+
override def getFile: File = null //TODO write b64 to file
28+
29+
override def getMediaType: String = "application/md"
30+
31+
}

dss-appconn/appconns/dss-sendemail-appconn/sendemail-appconn-core/src/main/scala/com/webank/wedatasphere/dss/appconn/sendemail/emailcontent/parser/PictureEmailContentParser.scala

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,15 @@ import java.awt.image.BufferedImage
2020
import java.io.{ByteArrayInputStream, ByteArrayOutputStream, InputStream}
2121
import java.util
2222
import java.util.{Base64, Iterator, UUID}
23-
24-
import com.webank.wedatasphere.dss.appconn.sendemail.email.domain.{AbstractEmail, ExcelAttachment, MultiContentEmail, PdfAttachment, PngAttachment}
23+
import com.webank.wedatasphere.dss.appconn.sendemail.email.domain.{AbstractEmail, ExcelAttachment, MdAttachment, MultiContentEmail, PdfAttachment, PngAttachment}
2524
import com.webank.wedatasphere.dss.appconn.sendemail.emailcontent.domain.PictureEmailContent
2625
import org.apache.linkis.common.conf.Configuration
26+
2727
import javax.imageio.{ImageIO, ImageReader}
2828
import org.apache.commons.codec.binary.Base64OutputStream
2929
import com.webank.wedatasphere.dss.appconn.sendemail.conf.SendEmailAppConnConfiguration._
3030
import com.webank.wedatasphere.dss.appconn.sendemail.exception.EmailSendFailedException
31+
3132
import javax.imageio.stream.ImageInputStream
3233
import org.apache.commons.io.IOUtils
3334
import org.apache.linkis.common.utils.Utils
@@ -46,6 +47,12 @@ object PictureEmailContentParser extends AbstractEmailContentParser[PictureEmail
4647
val decoder = Base64.getDecoder
4748
val byteArr = decoder.decode(imageStr)
4849
multiContentEmail.addAttachment(new PdfAttachment(pdfName, Base64.getEncoder.encodeToString(byteArr)))
50+
case "md" =>
51+
val mdUUID: String = UUID.randomUUID.toString
52+
val mdName = mdUUID + ".md"
53+
val decoder = Base64.getDecoder
54+
val byteArr = decoder.decode(imageStr)
55+
multiContentEmail.addAttachment(new MdAttachment(mdName, Base64.getEncoder.encodeToString(byteArr)))
4956
case "excel" =>
5057
//val excelUUID: String = UUID.randomUUID.toString
5158
val excelName = emailContent.getFileName + ".xlsx"

0 commit comments

Comments
 (0)