Jelajahi Sumber

修改minio的获取地址方法

785834757 3 bulan lalu
induk
melakukan
47d661e43d

+ 9 - 2
commons/src/main/java/com/jzg/commons/util/MinioUtils.java

@@ -12,6 +12,7 @@ import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.compress.utils.IOUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
 import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
 import org.springframework.stereotype.Component;
@@ -399,9 +400,15 @@ public class MinioUtils {
      */
     @SneakyThrows(Exception.class)
     public static String getPresignedObjectUrl(String bucketName, String objectName) {
+//        try {
+//            GetPresignedObjectUrlArgs args = GetPresignedObjectUrlArgs.builder().bucket(bucketName).object(objectName).method(Method.GET).build();
+//            return minioClient.getPresignedObjectUrl(args);
+//        } catch (Exception e) {
+//            return null;
+//        }
+        // 重新调整方法  minio 设置公开权限
         try {
-            GetPresignedObjectUrlArgs args = GetPresignedObjectUrlArgs.builder().bucket(bucketName).object(objectName).method(Method.GET).build();
-            return minioClient.getPresignedObjectUrl(args);
+            return "https://minio.baoxianzhanggui.com" + "/" + bucketName + "/" + objectName;
         } catch (Exception e) {
             return null;
         }