From ff803def4cd6dea63de5d51f0799fd736bd48e6f Mon Sep 17 00:00:00 2001
From: fwq <582742538@qq.com>
Date: 星期五, 10 六月 2022 15:32:12 +0800
Subject: [PATCH] redis设置锁

---
 src/main/java/com/hx/util/OBSUtil.java |   15 +++++++++++----
 1 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/src/main/java/com/hx/util/OBSUtil.java b/src/main/java/com/hx/util/OBSUtil.java
index fc74c7b..87b0ea8 100644
--- a/src/main/java/com/hx/util/OBSUtil.java
+++ b/src/main/java/com/hx/util/OBSUtil.java
@@ -32,7 +32,7 @@
 	 * @return
 	 * @throws IOException
 	 */
-	public static PutObjectResult uploadImg(MultipartFile localFile,String ak,String sk,String endPoint,String bucketName,String fileName) throws IOException {
+	public static PutObjectResult uploadImg(MultipartFile localFile,String ak,String sk,String endPoint,String bucketName,String folderName,String fileName) throws IOException {
 
 		//娌℃湁鍚嶆鐨勬椂鍊欒嚜鍔ㄧ敓鎴�
 		if(StringUtils.isNull(fileName)){
@@ -41,13 +41,16 @@
 				fileName += localFile.getOriginalFilename().substring(localFile.getOriginalFilename().lastIndexOf("."));
 			}
 		}
+		if(StringUtils.noNull(folderName)){
+			fileName = folderName+"/"+fileName;
+		}
 
 		PutObjectResult putObjectResult = null;
 
 		//鍒濆鍖朞BS瀹㈡埛绔�
 		ObsClient obsClient = new ObsClient(ak, sk, endPoint);
 		try{
-			putObjectResult = obsClient.putObject(bucketName, fileName,localFile.getInputStream());
+			putObjectResult = obsClient.putObject(bucketName,fileName , localFile.getInputStream());
 		}catch (ObsException e){
 			logger.error("鍗庝负浜� OBS 涓婁紶鏂囦欢鎶ラ敊 ");
 			logger.error("HTTP Code: " + e.getResponseCode());
@@ -73,11 +76,12 @@
 	 * @param sk 璁块棶绉橀挜
 	 * @param endPoint 鍖哄煙
 	 * @param bucketName 瀛樺偍妗�
+	 * @param folderName 鏂囦欢澶瑰悕绉�
 	 * @param fileName 鏂囦欢鍚嶇О锛堝甫鍚庣紑锛夛紝涓虹┖鏃惰嚜鍔ㄧ敓鎴�
 	 * @return
 	 * @throws IOException
 	 */
-	public static PutObjectResult uploadImg(File localFile,String ak,String sk,String endPoint,String bucketName,String fileName) throws IOException {
+	public static PutObjectResult uploadImg(File localFile,String ak,String sk,String endPoint,String bucketName,String folderName,String fileName) throws IOException {
 
 		//娌℃湁鍚嶆鐨勬椂鍊欒嚜鍔ㄧ敓鎴�
 		if(StringUtils.isNull(fileName)){
@@ -86,13 +90,16 @@
 				fileName += localFile.getName().substring(localFile.getName().lastIndexOf("."));
 			}
 		}
+		if(StringUtils.noNull(folderName)){
+			fileName = folderName+"/"+fileName;
+		}
 
 		PutObjectResult putObjectResult = null;
 
 		//鍒濆鍖朞BS瀹㈡埛绔�
 		ObsClient obsClient = new ObsClient(ak, sk, endPoint);
 		try{
-			putObjectResult = obsClient.putObject(bucketName, fileName,localFile);
+			putObjectResult = obsClient.putObject(bucketName, fileName, localFile);
 		}catch (ObsException e){
 			logger.error("鍗庝负浜� OBS 涓婁紶鏂囦欢鎶ラ敊 ");
 			logger.error("HTTP Code: " + e.getResponseCode());

--
Gitblit v1.8.0