mirror of
https://gitee.com/youlaitech/youlai-mall.git
synced 2024-12-22 20:54:26 +08:00
refactor: 删除文件接口入参由文件名修改为文件完整路径
This commit is contained in:
parent
3ddbe68a29
commit
73bb822d5d
@ -31,9 +31,9 @@ public class FileController {
|
||||
@ApiOperation(value = "文件删除")
|
||||
@SneakyThrows
|
||||
public Result deleteFile(
|
||||
@ApiParam("文件路径") @RequestParam String fileName
|
||||
@ApiParam("文件路径") @RequestParam String filePath
|
||||
) {
|
||||
boolean result = fileService.deleteFile(fileName);
|
||||
boolean result = fileService.deleteFile(filePath);
|
||||
return Result.judge(result);
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@ public interface FileService {
|
||||
/**
|
||||
* 删除文件
|
||||
*
|
||||
* @param filePath
|
||||
* @param filePath 文件路径
|
||||
* @return
|
||||
*/
|
||||
boolean deleteFile(String filePath);
|
||||
|
@ -73,6 +73,12 @@ public class MinioServiceImpl implements FileService, InitializingBean {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 上传文件
|
||||
*
|
||||
* @param file 表单文件对象
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@SneakyThrows
|
||||
public FileInfo uploadFile(MultipartFile file) {
|
||||
@ -115,11 +121,20 @@ public class MinioServiceImpl implements FileService, InitializingBean {
|
||||
return fileInfo;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 删除文件
|
||||
*
|
||||
* @param filePath 文件路径
|
||||
* https://oss.youlai.tech/default/2022/11/20/test.jpg
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@SneakyThrows
|
||||
public boolean deleteFile(String fileName) {
|
||||
public boolean deleteFile(String filePath) {
|
||||
Assert.notBlank(filePath, "删除文件路径不能为空");
|
||||
String tempStr = "/" + bucketName + "/";
|
||||
String fileName = filePath.substring(filePath.indexOf(tempStr) + tempStr.length()); // 2022/11/20/test.jpg
|
||||
|
||||
RemoveObjectArgs removeObjectArgs = RemoveObjectArgs.builder()
|
||||
.bucket(bucketName)
|
||||
.object(fileName)
|
||||
|
Loading…
Reference in New Issue
Block a user