mirror of
https://gitee.com/wangkang/udf.git
synced 2026-10-30 17:43:42 +00:00
文件上传到阿里云OSS的默认路径调整
This commit is contained in:
+3
-2
@@ -15,7 +15,8 @@ import org.springframework.stereotype.Component;
|
||||
import java.io.File;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URL;
|
||||
import java.sql.Date;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* OssWarpper
|
||||
@@ -195,7 +196,7 @@ public class OssWarpper {
|
||||
//实例化oss对象
|
||||
OSSClient client = new OSSClient(auth.getEndPoint(), auth.getAccessId(), auth.getAccessKey());
|
||||
try {
|
||||
String objectKey = "upload/" + file.getName();
|
||||
String objectKey = "upload/" + new SimpleDateFormat("yyyy-MM-dd").format(new Date()) + "/" + file.getName();
|
||||
client.putObject(path.getBucketName(), objectKey, file);
|
||||
return objectKey;
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user