Browse Source

修改:在前端无法做oss私有链接适配的情况下,暂且使用/internal目录来区分私有文件

dev_shibei_match
wxz 5 years ago
parent
commit
b9057df5c7
  1. 18
      epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/cloud/AbstractCloudStorageService.java

18
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 文件字节数组

Loading…
Cancel
Save