소스 검색

fix : Websocket图片消息处理

bilingfeng 1 년 전
부모
커밋
e6aeda7926

+ 1 - 1
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/ManageApplication.java

@@ -23,7 +23,7 @@ public class ManageApplication {
 
     public static void main(String[] args) {
         SpringApplication.run(ManageApplication.class, args);
-        System.out.println("赞象Manage服务启动成功 <Websocket图片消息处理> ( ´・・)ノ(._.`) \n" +
+        System.out.println("赞象Manage服务启动成功 <Websocket图片消息处理1> ( ´・・)ノ(._.`) \n" +
                 "___  ___  ___   _   _   ___  _____  _____ \n" +
                 "|  \\/  | / _ \\ | \\ | | / _ \\|  __ \\|  ___|\n" +
                 "| .  . |/ /_\\ \\|  \\| |/ /_\\ \\ |  \\/| |__  \n" +

+ 2 - 10
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/impl/KfAppletMsgServiceImpl.java

@@ -203,20 +203,12 @@ public class KfAppletMsgServiceImpl implements IKfAppletMsgService {
     private String mediaConvertOss(String mediaUrl) {
         //资源转换
         MultipartFile multipartFile = FileUtil.urlToMultipartFile(mediaUrl);
-        // 获取上传文件的MIME类型
-        String contentType = multipartFile.getContentType();
-        // 初始化文件格式为默认值
-        String fileFormat = "jpg";
-        // 判断MIME类型不为空并且包含"/"字符
-        if (contentType != null && contentType.contains("/")) {
-            fileFormat = contentType.substring(contentType.lastIndexOf("/") + 1);
-        }
         //生成唯一文件名
-        String fileName = Long.toString(System.currentTimeMillis(), 36) + SecurityUtil.getUserId() + "." + fileFormat;
+        String fileName = Long.toString(System.currentTimeMillis(), 36) + SecurityUtil.getUserId() + ".jpg";
         try {
             ossService.upload("image/" + fileName, multipartFile.getInputStream());
         } catch (IOException e) {
-            log.error("文件上传oss异常, mediaUrl : {}, fileFormat : {}, e : {}", mediaUrl, fileFormat, e.getMessage());
+            log.error("文件上传oss异常, mediaUrl : {}, e : {}", mediaUrl, e.getMessage());
             throw new BaseException("文件上传oss异常");
         }
         //oss资源地址