From 4e7907983a99e695f2acba4dec8bd73b7dbe6b2b Mon Sep 17 00:00:00 2001
From: java110 <928255095@qq.com>
Date: 星期四, 29 六月 2023 14:41:33 +0800
Subject: [PATCH] optimize

---
 java110-core/src/main/java/com/java110/core/client/CosUploadTemplate.java |   35 ++++++++++++++++++++++++++++++++++-
 1 files changed, 34 insertions(+), 1 deletions(-)

diff --git a/java110-core/src/main/java/com/java110/core/client/CosUploadTemplate.java b/java110-core/src/main/java/com/java110/core/client/CosUploadTemplate.java
index a92fcda..894f446 100644
--- a/java110-core/src/main/java/com/java110/core/client/CosUploadTemplate.java
+++ b/java110-core/src/main/java/com/java110/core/client/CosUploadTemplate.java
@@ -65,7 +65,7 @@
             byte[] context = Base64Convert.base64ToByte(imageBase64);
             is = new ByteArrayInputStream(context);
 
-            COSUtil.uploadByInputStream(cosClient, is,  ftpPath +urlPath);
+            COSUtil.uploadByInputStream(cosClient, is, ftpPath + urlPath);
         } catch (Exception e) {
             logger.error("涓婁紶鏂囦欢澶辫触", e);
             throw new IllegalArgumentException("涓婁紶鏂囦欢澶辫触");
@@ -109,6 +109,23 @@
             }
         }
         return fileName;
+    }
+
+    /*
+     *鏂囦欢涓婁紶宸ュ叿鏂规硶
+     */
+    public String upload(InputStream inputStream, String ftpPath) {
+        COSClient cosClient = null;
+        try {
+            cosClient = COSUtil.getCOSClient();
+            COSUtil.uploadByInputStream(cosClient, inputStream, ftpPath);
+        } catch (Exception e) {
+            // logger.error("涓婁紶鏂囦欢澶辫触", e);
+            throw new IllegalArgumentException("涓婁紶鏂囦欢澶辫触");
+        } finally {
+
+        }
+        return ftpPath;
     }
 
     /*
@@ -241,4 +258,20 @@
         return null;
     }
 
+    public InputStream download(String fileName) {
+        COSClient ossClient = null;
+        InputStream is = null;
+        try {
+            ossClient = COSUtil.getCOSClient();
+            is = COSUtil.getInputStreamByCOS(ossClient, fileName);
+            if (null == is) {
+                throw new FileNotFoundException(fileName);
+            }
+
+        } catch (Exception e) {
+            logger.error("ftp閫氳繃鏂囦欢鍚嶇О鑾峰彇杩滅▼鏂囦欢娴�", e);
+        }
+        return is;
+    }
+
 }

--
Gitblit v1.8.0