|
@@ -96,7 +96,10 @@ public class ImSendGroupMessageServiceImpl extends BaseServiceImpl<Long, ImSendG
|
|
|
|
|
|
private void send(ImSendGroupMessage messageDto) throws Exception {
|
|
|
if (Objects.equals(messageDto.getMessageType(), ImSendTypeEnum.IMG)) {
|
|
|
- String content = imageToBase64(Thumbnails.of(new URL(messageDto.getFileUrl())).scale(0.5f).outputQuality(0.25f).asBufferedImage());
|
|
|
+ URL url = new URL(messageDto.getFileUrl());
|
|
|
+ String path = url.getPath();
|
|
|
+ String suffix = path.substring(path.lastIndexOf(".") + 1);
|
|
|
+ String content = imageToBase64(Thumbnails.of(url).scale(0.5f).outputQuality(0.25f).asBufferedImage(),suffix);
|
|
|
sysMessageService.batchSendImGroupMessage(content,messageDto.getSenderId(),
|
|
|
messageDto.getExtra(),messageDto.getFileUrl(),messageDto.getTargetIds().split(","));
|
|
|
} else if (Objects.equals(messageDto.getMessageType(),ImSendTypeEnum.FILE)) {
|
|
@@ -108,11 +111,11 @@ public class ImSendGroupMessageServiceImpl extends BaseServiceImpl<Long, ImSendG
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public static String imageToBase64(BufferedImage bufferedImage) {
|
|
|
+ public static String imageToBase64(BufferedImage bufferedImage,String suffix) {
|
|
|
Base64 encoder = new Base64();
|
|
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
|
|
try {
|
|
|
- ImageIO.write(bufferedImage, "jpg", baos);
|
|
|
+ ImageIO.write(bufferedImage, suffix, baos);
|
|
|
} catch (IOException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|