diff --git a/ruoyi-api/ruoyi-api-resource/src/main/java/org/dromara/resource/api/RemoteFileService.java b/ruoyi-api/ruoyi-api-resource/src/main/java/org/dromara/resource/api/RemoteFileService.java index 2204de622..e2caa8c45 100644 --- a/ruoyi-api/ruoyi-api-resource/src/main/java/org/dromara/resource/api/RemoteFileService.java +++ b/ruoyi-api/ruoyi-api-resource/src/main/java/org/dromara/resource/api/RemoteFileService.java @@ -12,14 +12,6 @@ import java.util.List; */ public interface RemoteFileService { - /** - * 上传文件 - * - * @param file 文件信息 - * @return 结果 - */ - RemoteFile upload(String name, String originalFilename, String contentType, byte[] file) throws ServiceException; - /** * 通过ossId查询对应的url * diff --git a/ruoyi-api/ruoyi-api-resource/src/main/java/org/dromara/resource/api/RemoteFileServiceMock.java b/ruoyi-api/ruoyi-api-resource/src/main/java/org/dromara/resource/api/RemoteFileServiceMock.java index 5ce7c5a0b..95852e01c 100644 --- a/ruoyi-api/ruoyi-api-resource/src/main/java/org/dromara/resource/api/RemoteFileServiceMock.java +++ b/ruoyi-api/ruoyi-api-resource/src/main/java/org/dromara/resource/api/RemoteFileServiceMock.java @@ -14,18 +14,6 @@ import java.util.List; @Slf4j public class RemoteFileServiceMock implements RemoteFileService { - /** - * 上传文件 - * - * @param file 文件信息 - * @return 结果 - */ - @Override - public RemoteFile upload(String name, String originalFilename, String contentType, byte[] file) { - log.warn("服务调用异常 -> 降级处理"); - return null; - } - /** * 通过ossId查询对应的url * diff --git a/ruoyi-modules/ruoyi-resource/src/main/java/org/dromara/resource/dubbo/RemoteFileServiceImpl.java b/ruoyi-modules/ruoyi-resource/src/main/java/org/dromara/resource/dubbo/RemoteFileServiceImpl.java index 3265b39f0..5c57ab46e 100644 --- a/ruoyi-modules/ruoyi-resource/src/main/java/org/dromara/resource/dubbo/RemoteFileServiceImpl.java +++ b/ruoyi-modules/ruoyi-resource/src/main/java/org/dromara/resource/dubbo/RemoteFileServiceImpl.java @@ -35,43 +35,6 @@ public class RemoteFileServiceImpl implements RemoteFileService { private final ISysOssService sysOssService; - /** - * 文件上传请求 - */ - @Transactional(rollbackFor = Exception.class) - @Override - public RemoteFile upload(String name, String originalFilename, String contentType, byte[] file) throws ServiceException { - try { - String suffix = StringUtils.substring(originalFilename, originalFilename.lastIndexOf("."), originalFilename.length()); - OssClient instance = OssFactory.instance(); - String pathKey = instance.buildPathKey(originalFilename); - PutObjectResult result = instance.upload(pathKey, file); - // 保存文件信息 - SysOssBo oss = new SysOssBo(); - oss.setUrl(result.url()); - oss.setFileSuffix(suffix); - oss.setFileName(result.key()); - oss.setOriginalName(originalFilename); - oss.setService(instance.clientId()); - SysOssExt ext1 = new SysOssExt(); - ext1.setFileSize((long) file.length); - String extStr = JsonUtils.toJsonString(ext1); - oss.setExt1(extStr); - sysOssService.insertByBo(oss); - RemoteFile sysFile = new RemoteFile(); - sysFile.setOssId(oss.getOssId()); - sysFile.setName(result.key()); - sysFile.setUrl(result.url()); - sysFile.setOriginalName(originalFilename); - sysFile.setFileSuffix(suffix); - sysFile.setExt1(extStr); - return sysFile; - } catch (Exception e) { - log.error("上传文件失败", e); - throw new ServiceException("上传文件失败"); - } - } - /** * 通过ossId查询对应的url *