From 433a24418d8507212b036ccc8effdd4f57d20c8e Mon Sep 17 00:00:00 2001
From: 安瑾然 <m17681517455@outlook.com>
Date: 星期二, 21 二月 2023 14:15:34 +0800
Subject: [PATCH] fix:修改mybatis-plus日志打印方式,图片全路径获取函数修改
---
src/main/java/com/example/jz/service/impl/MinIOServiceImpl.java | 25 +++++++++----------------
1 files changed, 9 insertions(+), 16 deletions(-)
diff --git a/src/main/java/com/example/jz/service/impl/MinIOServiceImpl.java b/src/main/java/com/example/jz/service/impl/MinIOServiceImpl.java
index 4c3966d..9c4e1b4 100644
--- a/src/main/java/com/example/jz/service/impl/MinIOServiceImpl.java
+++ b/src/main/java/com/example/jz/service/impl/MinIOServiceImpl.java
@@ -4,22 +4,15 @@
import com.example.jz.config.MinIOConfig;
import com.example.jz.exception.BusinessException;
import com.example.jz.service.MinIOService;
-import io.minio.GetPresignedObjectUrlArgs;
import io.minio.MinioClient;
import io.minio.PutObjectOptions;
-import io.minio.UploadObjectArgs;
-import io.minio.errors.*;
-import io.minio.http.Method;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
-import java.io.IOException;
-import java.security.InvalidKeyException;
-import java.security.NoSuchAlgorithmException;
import java.text.SimpleDateFormat;
import java.util.Date;
-import java.util.concurrent.TimeUnit;
@Service
public class MinIOServiceImpl implements MinIOService {
@@ -28,20 +21,20 @@
@Autowired
MinIOConfig minIOConfig;
+ @Value("${minio.url}")
+ String url;
+
+ @Value("${minio.bucketName}")
+ String bucketName;
+
+
@Override
public String getPreviewFileUrl(String fileName) {
- String res = null;
try {
- res = minioClient.getPresignedObjectUrl(
- GetPresignedObjectUrlArgs.builder()
- .method(Method.GET)
- .bucket(minIOConfig.getBucketName())
- .object(fileName)
- .build());
+ return url + bucketName + '/' + fileName;
} catch (Exception e) {
throw new BusinessException("鑾峰彇鏂囦欢棰勮鍦板潃澶辫触");
}
- return res;
}
@Override
--
Gitblit v1.8.0