ソースを参照

图片添加水印

qin 1 年間 前
コミット
1f6fa85664

+ 6 - 1
src/main/java/com/poteviohealth/cgp/statistics/utils/OssUtils.java

@@ -9,6 +9,9 @@ import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Component;
 import org.springframework.web.multipart.MultipartFile;
 
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
 /**
  * 阿里云图片上传工具类
  * @author Qin
@@ -43,7 +46,9 @@ public class OssUtils {
                 if (pos != -1) {
                     suffix = dto.getOriginalFilename().substring(pos);
                 }
-                String fileName = dir+"S"+orderId+"N-"+ CgpTool.generateUUID() +suffix;
+            SimpleDateFormat format = new SimpleDateFormat("yyMM");
+            String dirStr = dir+format.format(new Date());
+                String fileName = dirStr+"/S"+orderId+"N-"+ CgpTool.generateUUID() +suffix;
                 // 创建PutObject请求。
                 ossClient.putObject(bucketName, fileName, dto.getInputStream());