mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-22 15:21:53 +08:00
统一 FileApi 的封装,与 yudao-cloud~
This commit is contained in:
parent
d3fe187696
commit
9c5befaf9d
@ -13,7 +13,7 @@ public interface FileApi {
|
||||
* @param content 文件内容
|
||||
* @return 文件路径
|
||||
*/
|
||||
default String createFile(byte[] content) throws Exception {
|
||||
default String createFile(byte[] content) {
|
||||
return createFile(null, null, content);
|
||||
}
|
||||
|
||||
@ -24,18 +24,18 @@ public interface FileApi {
|
||||
* @param content 文件内容
|
||||
* @return 文件路径
|
||||
*/
|
||||
default String createFile(String path, byte[] content) throws Exception {
|
||||
default String createFile(String path, byte[] content) {
|
||||
return createFile(null, path, content);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存文件,并返回文件的访问路径
|
||||
*
|
||||
* @param name 原文件名称
|
||||
* @param name 文件名称
|
||||
* @param path 文件路径
|
||||
* @param content 文件内容
|
||||
* @return 文件路径
|
||||
*/
|
||||
String createFile(String name, String path, byte[] content) throws Exception;
|
||||
String createFile(String name, String path, byte[] content);
|
||||
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ public class FileApiImpl implements FileApi {
|
||||
private FileService fileService;
|
||||
|
||||
@Override
|
||||
public String createFile(String name, String path, byte[] content) throws Exception {
|
||||
public String createFile(String name, String path, byte[] content) {
|
||||
return fileService.createFile(name, path, content);
|
||||
}
|
||||
|
||||
|
@ -22,12 +22,12 @@ public interface FileService {
|
||||
/**
|
||||
* 保存文件,并返回文件的访问路径
|
||||
*
|
||||
* @param name 原文件名称
|
||||
* @param name 文件名称
|
||||
* @param path 文件路径
|
||||
* @param content 文件内容
|
||||
* @return 文件路径
|
||||
*/
|
||||
String createFile(String name, String path, byte[] content) throws Exception;
|
||||
String createFile(String name, String path, byte[] content);
|
||||
|
||||
/**
|
||||
* 删除文件
|
||||
|
@ -9,6 +9,7 @@ import cn.iocoder.yudao.framework.file.core.client.FileClient;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.file.vo.file.FilePageReqVO;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.file.FileDO;
|
||||
import cn.iocoder.yudao.module.infra.dal.mysql.file.FileMapper;
|
||||
import lombok.SneakyThrows;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
@ -37,7 +38,8 @@ public class FileServiceImpl implements FileService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createFile(String name, String path, byte[] content) throws Exception {
|
||||
@SneakyThrows
|
||||
public String createFile(String name, String path, byte[] content) {
|
||||
// 计算默认的 path 名
|
||||
String type = FileTypeUtil.getType(new ByteArrayInputStream(content), name);
|
||||
if (StrUtil.isEmpty(path)) {
|
||||
|
Loading…
Reference in New Issue
Block a user