mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-21 03:25:12 +08:00
update 修改图片上传名称
This commit is contained in:
@@ -3,13 +3,13 @@ package com.jsowell.common.util.file;
|
||||
import com.aliyun.oss.OSS;
|
||||
import com.aliyun.oss.OSSClientBuilder;
|
||||
import com.jsowell.common.config.AliyunOssConfig;
|
||||
import com.jsowell.common.util.RandomUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneOffset;
|
||||
|
||||
@Component
|
||||
public class AliyunOssUploadUtils {
|
||||
@@ -44,10 +44,10 @@ public class AliyunOssUploadUtils {
|
||||
|
||||
//获取当前时间
|
||||
LocalDateTime currentDate = LocalDateTime.now();
|
||||
String dir_name = currentDate.getYear() + "/" + currentDate.getMonthValue() + "/";
|
||||
String dir_name = currentDate.getYear() + "/" + currentDate.getMonthValue() + "/" + currentDate.getDayOfMonth() + "/";
|
||||
|
||||
// 随机数
|
||||
String randomNumber = RandomUtil.getRandomNumber(5) + "-";
|
||||
String randomNumber = Long.toHexString(currentDate.toEpochSecond(ZoneOffset.UTC)) + "-";
|
||||
|
||||
// 文件路径名称
|
||||
filePathName = aliyunOssConfig.getFilehost() + "/" + dir_name + randomNumber + filePathName;
|
||||
|
||||
Reference in New Issue
Block a user