Browse Source

update https上传文件

A17404李放 3 năm trước cách đây
mục cha
commit
f2e85092db

+ 1 - 1
nb-common/src/main/java/com/nb/common/config/sa/SaTokenActionDefaultImpl.java

@@ -161,7 +161,7 @@ public class SaTokenActionDefaultImpl implements SaTokenAction {
 	 */
 	public static boolean vagueMatch(String patt, String str) {
 		// 如果表达式不带有*号,则只需简单equals即可 (速度提升200倍)
-		if(str.contains("*")&&patt.contains("*")) {
+		if(!str.contains("*")&&!patt.contains("*")) {
 			return patt.equals(str);
 		}
 		return Pattern.matches(str.replaceAll("\\*", ".*"), patt)||Pattern.matches(patt.replaceAll("\\*", ".*"), str);

+ 1 - 1
nb-common/src/main/java/com/nb/common/util/MinioUtil.java

@@ -51,7 +51,7 @@ public class MinioUtil {
             log.error("上传文件失败,{}", e.getMessage());
             throw new CustomException("上传文件失败," + e.getMessage());
         }
-        return (minioConfig.isSecure()?"https:":"http:")+minioConfig.getEndpoint()+":"+minioConfig.getPort() + "/" + minioConfig.getBucketName() + filepath;
+        return  "/" + minioConfig.getBucketName() + filepath;
     }
 
 }

+ 1 - 0
nb-oss/src/main/java/com/nb/oss/strategy/impl/AliyunStorageStrategy.java

@@ -23,4 +23,5 @@ public class AliyunStorageStrategy extends AbstractFileStorage {
     public SysStorage upload(MultipartFile file, String bizPath) {
         return null;
     }
+
 }

+ 2 - 1
nb-oss/src/main/java/com/nb/oss/strategy/impl/MinioStorageStrategy.java

@@ -46,9 +46,10 @@ public class MinioStorageStrategy extends AbstractFileStorage {
         String type = FileUtil.getFileType(suffix);
         String filepath = this.getFilepath(file, bizPath);
         String url = minioUtils.uploadObject(file.getInputStream(), filepath);
+        String urlPrefix= (minioConfig.isSecure()?"https:":"http:")+minioConfig.getEndpoint()+":"+minioConfig.getPort() ;
         name = CharSequenceUtil.isBlank(name) ? FileUtil.getFileNameNoEx(file.getOriginalFilename()) : name;
 
-        SysStorage localStorage = new SysStorage(file.getName(), name, suffix,url, type,
+        SysStorage localStorage = new SysStorage(file.getName(), name, suffix,urlPrefix,url, type,
                 file.getSize());
 
         sysStorageService.save(localStorage);

+ 7 - 11
nb-oss/src/main/java/com/nb/oss/strategy/storage/SysStorage.java

@@ -15,6 +15,7 @@
  */
 package com.nb.oss.strategy.storage;
 
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.nb.common.entity.GenericEntity;
 import io.swagger.annotations.ApiModel;
@@ -47,6 +48,9 @@ public class SysStorage extends GenericEntity<String> implements Serializable {
     @ApiModelProperty(value = "后缀")
     private String suffix;
 
+    @ApiModelProperty(value = "url前缀")
+    private String urlPrefix;
+
     @ApiModelProperty(value = "路径")
     private String url;
 
@@ -59,23 +63,15 @@ public class SysStorage extends GenericEntity<String> implements Serializable {
     @ApiModelProperty("版本号")
     private String version;
 
-    public SysStorage(String realName, String name, String suffix, String path, String type, Long size) {
+    public SysStorage(String realName, String name, String suffix, String urlPrefix, String url, String type, Long size) {
         this.realName = realName;
         this.name = name;
         this.suffix = suffix;
-        this.url = path;
+        this.url = url;
+        this.urlPrefix=urlPrefix;
         this.type = type;
         this.size = size;
         this.version=null;
     }
 
-    public SysStorage(String realName, String name, String suffix, String path, String type, Long size,String version) {
-        this.realName = realName;
-        this.name = name;
-        this.suffix = suffix;
-        this.url = path;
-        this.type = type;
-        this.size = size;
-        this.version=version;
-    }
 }

+ 4 - 0
nb-system/src/main/java/com/nb/bus/entity/BusVersionEntity.java

@@ -43,6 +43,10 @@ public class BusVersionEntity extends GenericEntity<String> implements Serializa
     @ApiModelProperty("安装包存储url")
     private String url;
 
+    /**
+     * 存储id
+     */
+    private String storageId;
     /**
      * 版本号
      */