diff --git a/im-platform/src/main/java/com/bx/implatform/contant/Constant.java b/im-platform/src/main/java/com/bx/implatform/contant/Constant.java index af18830..6d23dfc 100644 --- a/im-platform/src/main/java/com/bx/implatform/contant/Constant.java +++ b/im-platform/src/main/java/com/bx/implatform/contant/Constant.java @@ -8,11 +8,11 @@ public final class Constant { /** * 最大图片上传大小 */ - public static final long MAX_IMAGE_SIZE = 5 * 1024 * 1024; + public static final long MAX_IMAGE_SIZE = 20 * 1024 * 1024; /** * 最大上传文件大小 */ - public static final long MAX_FILE_SIZE = 10 * 1024 * 1024; + public static final long MAX_FILE_SIZE = 20 * 1024 * 1024; /** * 群聊最大人数 */ diff --git a/im-platform/src/main/java/com/bx/implatform/service/thirdparty/FileService.java b/im-platform/src/main/java/com/bx/implatform/service/thirdparty/FileService.java index 91935d9..b727425 100644 --- a/im-platform/src/main/java/com/bx/implatform/service/thirdparty/FileService.java +++ b/im-platform/src/main/java/com/bx/implatform/service/thirdparty/FileService.java @@ -59,7 +59,7 @@ public class FileService { Long userId = SessionContext.getSession().getUserId(); // 大小校验 if (file.getSize() > Constant.MAX_FILE_SIZE) { - throw new GlobalException(ResultCode.PROGRAM_ERROR, "文件大小不能超过10M"); + throw new GlobalException(ResultCode.PROGRAM_ERROR, "文件大小不能超过20M"); } // 上传 String fileName = minioUtil.upload(bucketName, filePath, file); @@ -76,7 +76,7 @@ public class FileService { Long userId = SessionContext.getSession().getUserId(); // 大小校验 if (file.getSize() > Constant.MAX_IMAGE_SIZE) { - throw new GlobalException(ResultCode.PROGRAM_ERROR, "图片大小不能超过5M"); + throw new GlobalException(ResultCode.PROGRAM_ERROR, "图片大小不能超过20M"); } // 图片格式校验 if (!FileUtil.isImage(file.getOriginalFilename())) { diff --git a/im-uniapp/components/image-upload/image-upload.vue b/im-uniapp/components/image-upload/image-upload.vue index 09e41a9..de625c3 100644 --- a/im-uniapp/components/image-upload/image-upload.vue +++ b/im-uniapp/components/image-upload/image-upload.vue @@ -50,13 +50,7 @@ sizeType: ['original'], //original 原图,compressed 压缩图,默认二者都有 success: (res) => { res.tempFiles.forEach((file) => { - // 校验大小 - if (this.maxSize && file.size > this.maxSize) { - this.$message.error(`文件大小不能超过 ${this.fileSizeStr}!`); - this.$emit("fail", file); - return; - } - + console.log("文件:",file) if (!this.onBefore || this.onBefore(file)) { // 调用上传图片的接口 this.uploadImage(file); @@ -76,6 +70,10 @@ success: (res) => { let data = JSON.parse(res.data); if(data.code != 200){ + uni.showToast({ + icon: "none", + title: data.message, + }) this.onError && this.onError(file, data); }else{ this.onSuccess && this.onSuccess(file, data); @@ -87,17 +85,6 @@ } }) } - }, - computed: { - fileSizeStr() { - if (this.maxSize > 1024 * 1024) { - return Math.round(this.maxSize / 1024 / 1024) + "M"; - } - if (this.maxSize > 1024) { - return Math.round(this.maxSize / 1024) + "KB"; - } - return this.maxSize + "B"; - } } }