【7.1.6】【file】修复文件存储类型的错误

pull/25/head
fengshuonan 2022-01-02 20:56:21 +08:00
parent e10eec144f
commit a33b413456
6 changed files with 35 additions and 2 deletions

View File

@ -25,6 +25,7 @@
package cn.stylefeng.roses.kernel.file.api;
import cn.stylefeng.roses.kernel.file.api.enums.BucketAuthEnum;
import cn.stylefeng.roses.kernel.file.api.enums.FileLocationEnum;
import java.io.InputStream;
@ -188,4 +189,12 @@ public interface FileOperatorApi {
*/
void deleteFile(String bucketName, String key);
/**
* api
*
* @author fengshuonan
* @date 2022/1/2 20:50
*/
FileLocationEnum getFileLocationEnum();
}

View File

@ -31,7 +31,6 @@ import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.spring.SpringUtil;
import cn.stylefeng.roses.kernel.file.api.FileOperatorApi;
import cn.stylefeng.roses.kernel.file.api.enums.FileLocationEnum;
import cn.stylefeng.roses.kernel.file.api.enums.FileStatusEnum;
import cn.stylefeng.roses.kernel.file.api.exception.FileException;
import cn.stylefeng.roses.kernel.file.api.exception.enums.FileExceptionEnum;
@ -103,7 +102,7 @@ public class FileInfoFactory {
// 封装存储文件信息(上传替换公共信息)
SysFileInfo sysFileInfo = new SysFileInfo();
sysFileInfo.setFileId(fileId);
sysFileInfo.setFileLocation(FileLocationEnum.LOCAL.getCode());
sysFileInfo.setFileLocation(fileOperatorApi.getFileLocationEnum().getCode());
sysFileInfo.setFileBucket(fileBucket);
sysFileInfo.setFileObjectName(finalFileName);
sysFileInfo.setFileOriginName(originalFilename);

View File

@ -28,6 +28,7 @@ import cn.hutool.core.io.IoUtil;
import cn.hutool.core.util.StrUtil;
import cn.stylefeng.roses.kernel.file.api.FileOperatorApi;
import cn.stylefeng.roses.kernel.file.api.enums.BucketAuthEnum;
import cn.stylefeng.roses.kernel.file.api.enums.FileLocationEnum;
import cn.stylefeng.roses.kernel.file.api.exception.FileException;
import cn.stylefeng.roses.kernel.file.api.exception.enums.FileExceptionEnum;
import cn.stylefeng.roses.kernel.file.api.pojo.props.AliyunOssProperties;
@ -209,4 +210,9 @@ public class AliyunFileOperator implements FileOperatorApi {
ossClient.deleteObject(bucketName, key);
}
@Override
public FileLocationEnum getFileLocationEnum() {
return FileLocationEnum.ALIYUN;
}
}

View File

@ -31,6 +31,7 @@ import cn.stylefeng.roses.kernel.auth.api.context.LoginContext;
import cn.stylefeng.roses.kernel.file.api.FileOperatorApi;
import cn.stylefeng.roses.kernel.file.api.constants.FileConstants;
import cn.stylefeng.roses.kernel.file.api.enums.BucketAuthEnum;
import cn.stylefeng.roses.kernel.file.api.enums.FileLocationEnum;
import cn.stylefeng.roses.kernel.file.api.exception.FileException;
import cn.stylefeng.roses.kernel.file.api.exception.enums.FileExceptionEnum;
import cn.stylefeng.roses.kernel.file.api.expander.FileConfigExpander;
@ -199,4 +200,10 @@ public class LocalFileOperator implements FileOperatorApi {
FileUtil.del(file);
}
@Override
public FileLocationEnum getFileLocationEnum() {
return FileLocationEnum.LOCAL;
}
}

View File

@ -31,6 +31,7 @@ import cn.stylefeng.roses.kernel.auth.api.context.LoginContext;
import cn.stylefeng.roses.kernel.file.api.FileOperatorApi;
import cn.stylefeng.roses.kernel.file.api.constants.FileConstants;
import cn.stylefeng.roses.kernel.file.api.enums.BucketAuthEnum;
import cn.stylefeng.roses.kernel.file.api.enums.FileLocationEnum;
import cn.stylefeng.roses.kernel.file.api.exception.FileException;
import cn.stylefeng.roses.kernel.file.api.exception.enums.FileExceptionEnum;
import cn.stylefeng.roses.kernel.file.api.expander.FileConfigExpander;
@ -233,6 +234,11 @@ public class MinIoFileOperator implements FileOperatorApi {
}
@Override
public FileLocationEnum getFileLocationEnum() {
return FileLocationEnum.MINIO;
}
/**
* contentType
*

View File

@ -28,6 +28,7 @@ import cn.hutool.core.io.IoUtil;
import cn.hutool.core.thread.ExecutorBuilder;
import cn.stylefeng.roses.kernel.file.api.FileOperatorApi;
import cn.stylefeng.roses.kernel.file.api.enums.BucketAuthEnum;
import cn.stylefeng.roses.kernel.file.api.enums.FileLocationEnum;
import cn.stylefeng.roses.kernel.file.api.exception.FileException;
import cn.stylefeng.roses.kernel.file.api.exception.enums.FileExceptionEnum;
import cn.stylefeng.roses.kernel.file.api.expander.FileConfigExpander;
@ -261,4 +262,9 @@ public class TenFileOperator implements FileOperatorApi {
cosClient.deleteObject(bucketName, key);
}
@Override
public FileLocationEnum getFileLocationEnum() {
return FileLocationEnum.TENCENT;
}
}