From 6b479c5774ed3d6e2dc92693ddeda3e7ad1494db Mon Sep 17 00:00:00 2001
From: Andru <769883346@qq.com>
Date: 星期一, 23 十月 2023 17:34:08 +0800
Subject: [PATCH] 添加获客方法

---
 src/main/java/com/hx/util/OBSUtil.java |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/src/main/java/com/hx/util/OBSUtil.java b/src/main/java/com/hx/util/OBSUtil.java
index 56be8ed..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,6 +90,9 @@
 				fileName += localFile.getName().substring(localFile.getName().lastIndexOf("."));
 			}
 		}
+		if(StringUtils.noNull(folderName)){
+			fileName = folderName+"/"+fileName;
+		}
 
 		PutObjectResult putObjectResult = null;
 

--
Gitblit v1.8.0