文件服务配置
分布式文件服务
S7 数智化审计平台 默认支持的分布式文件存储服务为 MinIO,需要配置 MinIO 的 minioEndpoint、minioAccessKey、minioSecretKey,实现类为 com.yonyouaud.files.service.impl.MinIoStorageService。
ais: # S7 配置
file: # minio storage host info
storage: com.yonyouaud.files.service.impl.MinIoStorageService
minioEndpoint: http://10.2.112.83:9000
minioAccessKey: RIcuzE1L1rxhV1kA
minioSecretKey: Nc9i3nMPsfvmz73LPG5zzvt9RuvLFEU8请确认
MinIO服务已经启动,并且配置的minioEndpoint、minioAccessKey、minioSecretKey与MinIO服务的配置一致。
更多 MinIO 资料请参考 MinIO 官网 (opens in a new tab)。
单机文件服务
单机文件服务,只需要配置文件存储路径即可,实现类为 com.yonyouaud.files.service.impl.LocalStorageService,所有的文件都会存储在本地的指定目录下(如下例中的 /ais/upload)。
ais: # S7 配置
file: # local storage
upload: /ais/upload
storage: com.yonyouaud.files.service.impl.LocalStorageService请确认配置的目录有读写权限。
自定义文件服务
可以扩展实现 S7 文件服务,实现 com.yonyouaud.commons.file.FileService 接口,然后在配置文件中配置 storage 为自定义实现类的全限定名即可。
ais: # S7 配置
file: # custome storage
storage: com.yonyouaud.files.service.impl.MyFileServiceFileService 接口定义
public interface FileService {
FileSpecVO saveFile(MultipartFile file, String formId, String formDataId, String category) throws IOException;
List<FileSpecVO> saveFiles(List<MultipartFile> files, String formId, String formDataId, String category) throws IOException;
List<File> getFilesWithName(String name, boolean includeDeleted);
File getFileWithName(String name, boolean includeDeleted);
List<File> getFilesWithFormDataId(String formDataId, boolean includeDeleted);
FileSpecVO getFileWithId(String id, boolean includeDeleted);
boolean deleteFile(String id);
boolean deleteFilesWithFormDataId(String formDataId);
List<FileSpecVO> getFileSpecsWithDataId(String formDataId);
List<FileSpecVO> getFileSpecsWithDataIdAndCategory(String formDataId, String category);
List<FileSpecVO> getFileSpecsWithDataIdAndCategorys(String formDataId, List<String> categorys);
List<FileSpecVO> getFileSpecsWithDataIDs(List<String> formDataIds);
void download(String id, HttpServletResponse response) throws IOException;
boolean copyFile(FileSpecVO source, FileSpecVO dest);
boolean save(FileSpecVO fileSpecVO);
void updateFile(String id, InputStream inputStream);
InputStream get(FileSpecVO fileSpec);
void saveFileOnly(FileSpecVO fileSpecVO, InputStream inputStream);
void deleteFileOnly(FileSpecVO fileSpecVO);
}