From b9057df5c7d80503b8ed6962e17b70a921ac9197 Mon Sep 17 00:00:00 2001 From: wxz Date: Mon, 4 Jan 2021 17:08:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=EF=BC=9A=E5=9C=A8=E5=89=8D?= =?UTF-8?q?=E7=AB=AF=E6=97=A0=E6=B3=95=E5=81=9Aoss=E7=A7=81=E6=9C=89?= =?UTF-8?q?=E9=93=BE=E6=8E=A5=E9=80=82=E9=85=8D=E7=9A=84=E6=83=85=E5=86=B5?= =?UTF-8?q?=E4=B8=8B=EF=BC=8C=E6=9A=82=E4=B8=94=E4=BD=BF=E7=94=A8/internal?= =?UTF-8?q?=E7=9B=AE=E5=BD=95=E6=9D=A5=E5=8C=BA=E5=88=86=E7=A7=81=E6=9C=89?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cloud/AbstractCloudStorageService.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) 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 文件字节数组