Selaa lähdekoodia

文件上传优化

xie.bx 2 vuotta sitten
vanhempi
commit
8d6d6c2b0f

+ 10 - 6
im-platform/src/main/java/com/bx/implatform/service/thirdparty/FileService.java

@@ -19,10 +19,12 @@ import org.springframework.web.multipart.MultipartFile;
 import javax.annotation.PostConstruct;
 import java.io.IOException;
 
-/*
+/**
+ * todo 通过校验文件MD5实现重复文件秒传
  * 文件上传服务
  * @Author Blue
  * @Date 2022/10/28
+ *
  */
 @Slf4j
 @Service
@@ -87,11 +89,13 @@ public class FileService {
                 throw new GlobalException(ResultCode.PROGRAM_ERROR,"图片上传失败");
             }
             vo.setOriginUrl(generUrl(FileType.IMAGE,fileName));
-            // 上传缩略图
-            byte[] imageByte = ImageUtil.compressForScale(file.getBytes(),100);
-            fileName = minioUtil.upload(bucketName,imagePath,file.getOriginalFilename(),imageByte,file.getContentType());
-            if(StringUtils.isEmpty(fileName)){
-                throw new GlobalException(ResultCode.PROGRAM_ERROR,"图片上传失败");
+            // 大于30K的文件需上传缩略图
+            if(file.getSize() > 30 * 1024){
+                byte[] imageByte = ImageUtil.compressForScale(file.getBytes(),30);
+                fileName = minioUtil.upload(bucketName,imagePath,file.getOriginalFilename(),imageByte,file.getContentType());
+                if(StringUtils.isEmpty(fileName)){
+                    throw new GlobalException(ResultCode.PROGRAM_ERROR,"图片上传失败");
+                }
             }
             vo.setThumbUrl(generUrl(FileType.IMAGE,fileName));
             log.info("文件图片成功,用户id:{},url:{}",userId,vo.getOriginUrl());

+ 0 - 6
im-ui/src/view/Home.vue

@@ -29,12 +29,6 @@
 				<el-menu-item title="设置" @click="showSetting()">
 					<span class="el-icon-setting"></span>
 				</el-menu-item>
-				<el-menu-item title="小伙子这么帅,点点star吧~">
-					<a href="https://gitee.com/bluexsx/box-im" target="_blank">
-						<el-image style="width: 30px; height: 30px" src="https://gitee.com/favicon.ico" fit="fit">
-						</el-image>
-					</a>
-				</el-menu-item>
 			</el-menu>
 			
 			<div class="exit-box" @click="handleExit()" title="退出">