feat(video): 新增模型管理与MinIO对象存储功能

- 新增算法模型实体类VModel及对应CRUD接口和实现
- 新增MinIO对象记录实体类VMinioObject及对应CRUD接口和实现
- 实现模型下载重定向功能
- 扩展MinioService支持指定文件名上传和删除对象
- 在CommonController中增加上传后持久化MinIO对象记录逻辑
- 新增ModelController用于模型管理RESTful接口- 新增VMinioObjectController用于MinIO对象记录管理接口
- 添加相关Mapper XML配置和DAO接口
- 更新pom.xml引入必要依赖
This commit is contained in:
2025-09-29 10:37:12 +08:00
parent e4f0c65478
commit af815e00ee
16 changed files with 611 additions and 4 deletions

View File

@@ -4,6 +4,7 @@ import com.ruoyi.framework.config.MinioProperties;
import com.ruoyi.common.utils.file.FileUploadUtils;
import io.minio.BucketExistsArgs;
import io.minio.MakeBucketArgs;
import io.minio.RemoveObjectArgs;
import io.minio.MinioClient;
import io.minio.PutObjectArgs;
import org.springframework.beans.factory.annotation.Autowired;
@@ -44,6 +45,25 @@ public class MinioService {
return new UploadResult(objectName, url);
}
/**
* Upload using the provided unique objectName.
*/
public UploadResult uploadWithName(MultipartFile file, String objectName) throws Exception {
ensureBucket();
try (InputStream is = file.getInputStream()) {
minioClient.putObject(
PutObjectArgs.builder()
.bucket(properties.getBucket())
.object(objectName)
.stream(is, file.getSize(), -1)
.contentType(file.getContentType())
.build()
);
}
String url = buildObjectUrl(objectName);
return new UploadResult(objectName, url);
}
public String buildObjectUrl(String objectName) {
String endpoint = properties.getEndpoint();
if (endpoint.endsWith("/")) {
@@ -63,6 +83,18 @@ public class MinioService {
}
}
/**
* Delete an object from MinIO by its object name (key).
*/
public void deleteObject(String objectName) throws Exception {
minioClient.removeObject(
RemoveObjectArgs.builder()
.bucket(properties.getBucket())
.object(objectName)
.build()
);
}
public static class UploadResult {
private final String objectName;
private final String url;