diff --git a/bonus-api/bonus-api-system/src/main/java/com/bonus/system/api/RemoteFileService.java b/bonus-api/bonus-api-system/src/main/java/com/bonus/system/api/RemoteFileService.java index c9574d7..c5a907c 100644 --- a/bonus-api/bonus-api-system/src/main/java/com/bonus/system/api/RemoteFileService.java +++ b/bonus-api/bonus-api-system/src/main/java/com/bonus/system/api/RemoteFileService.java @@ -3,7 +3,9 @@ package com.bonus.system.api; import com.bonus.common.core.web.domain.AjaxResult; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; import com.bonus.common.core.constant.ServiceNameConstants; @@ -34,4 +36,13 @@ public interface RemoteFileService */ @PostMapping(value = "/uploadFiles", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) public AjaxResult uploadFile(@RequestPart(value = "files") MultipartFile[] files); + + /** + * 文件删除 + * 从各个存储平台删除文件 + * @param objectKey * @param objectKey,除mongodb 存fileid之外,其他均存上传文件的网络路径 + * @return 成功或失败信息 + */ + @DeleteMapping("/deleteFile") + public AjaxResult deleteFile(@RequestParam("objectKey") String objectKey); } diff --git a/bonus-api/bonus-api-system/src/main/java/com/bonus/system/api/factory/RemoteFileFallbackFactory.java b/bonus-api/bonus-api-system/src/main/java/com/bonus/system/api/factory/RemoteFileFallbackFactory.java index 8dc63fd..9057fc6 100644 --- a/bonus-api/bonus-api-system/src/main/java/com/bonus/system/api/factory/RemoteFileFallbackFactory.java +++ b/bonus-api/bonus-api-system/src/main/java/com/bonus/system/api/factory/RemoteFileFallbackFactory.java @@ -36,6 +36,11 @@ public class RemoteFileFallbackFactory implements FallbackFactory DEFAULT_MAX_SIZE) - { - throw new FileSizeLimitExceededException(DEFAULT_MAX_SIZE / 1024 / 1024); - } +// 这里不验证文件大小,使用Spring MVC中上传文件的最大大小 spring.servlet.multipart.max-file-size +// long size = file.getSize(); +// if (size > DEFAULT_MAX_SIZE) +// { +// throw new FileSizeLimitExceededException(DEFAULT_MAX_SIZE / 1024 / 1024); +// } String fileName = file.getOriginalFilename(); String extension = FileTypeUtils.getExtension(file);