diff --git a/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/cloud/AbstractCloudStorageService.java b/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/cloud/AbstractCloudStorageService.java index bd88d9b50a..0eabc11add 100644 --- a/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/cloud/AbstractCloudStorageService.java +++ b/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/cloud/AbstractCloudStorageService.java @@ -9,6 +9,7 @@ package com.epmet.cloud; import com.epmet.commons.tools.utils.DateUtils; +import com.epmet.constants.PrivacyType; import org.apache.commons.lang3.StringUtils; import java.io.IOException; @@ -31,19 +32,32 @@ public abstract class AbstractCloudStorageService { * @param suffix 后缀 * @return 返回上传路径 */ - public String getPath(String prefix, String suffix) { + public String getPath(String prefix, String suffix, String privacy) { //生成uuid String uuid = UUID.randomUUID().toString().replaceAll("-", ""); //文件路径 String path = DateUtils.format(new Date(), "yyyyMMdd") + "/" + uuid; if(StringUtils.isNotBlank(prefix)){ - path = prefix + "/" + path; + path = prefix + "/" + getPrivacyPath(privacy) + path; } return path + "." + suffix; } + /** + * @Description 根据隐私级别获取隐私文件夹(在epmet-cloud-internal这个bucket正式启用之前生效) + * @return + * @author wxz + * @date 2021.01.04 16:55 + */ + private String getPrivacyPath(String privacy) { + if (PrivacyType.INTERNAL.equalsIgnoreCase(privacy)) { + return "internal/"; + } + return ""; + } + /** * 文件上传 * @param data 文件字节数组