From 275f1b9b7ec7fd0a8c5bb65a8d64ed23c6d57c13 Mon Sep 17 00:00:00 2001 From: wangkang Date: Mon, 18 Dec 2017 11:18:01 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=87=E4=BB=B6=E4=B8=8A=E4=BC=A0=E5=88=B0?= =?UTF-8?q?=E9=98=BF=E9=87=8C=E4=BA=91OSS=E7=9A=84=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E8=B7=AF=E5=BE=84=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/org/itkk/udf/file/aliyun/oss/api/OssWarpper.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/udf-starter-file-aliyun-oss-api/src/main/java/org/itkk/udf/file/aliyun/oss/api/OssWarpper.java b/udf-starter-file-aliyun-oss-api/src/main/java/org/itkk/udf/file/aliyun/oss/api/OssWarpper.java index 7825437..135adf1 100644 --- a/udf-starter-file-aliyun-oss-api/src/main/java/org/itkk/udf/file/aliyun/oss/api/OssWarpper.java +++ b/udf-starter-file-aliyun-oss-api/src/main/java/org/itkk/udf/file/aliyun/oss/api/OssWarpper.java @@ -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 {