Browse Source

图片查重

qin 1 năm trước cách đây
mục cha
commit
7fce83010f

+ 2 - 0
src/main/java/com/poteviohealth/cgp/statistics/controller/OrderController.java

@@ -249,8 +249,10 @@ public class OrderController extends BaseWebController {
         VaultsResponse<String> vaultsResponse = ossUtils.uploadOneFile(file,orderId);
         log.info(vaultsResponse.getData());
         return vaultsResponse;*/
+
         //图片检查
         try {
+            ossUtils.getFile("");
             InputStream inputStream = file.getInputStream();
             DistinctionDTO dto;
             Integer pos = file.getOriginalFilename().lastIndexOf('.');

+ 25 - 0
src/main/java/com/poteviohealth/cgp/statistics/utils/OssUtils.java

@@ -4,6 +4,7 @@ import com.aliyun.oss.OSS;
 import com.aliyun.oss.OSSClientBuilder;
 import com.poteviohealth.cgp.common.model.VaultsResponse;
 import com.poteviohealth.cgp.common.utils.CgpTool;
+import com.poteviohealth.cgp.common.utils.ImageUtils;
 import lombok.extern.log4j.Log4j2;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Component;
@@ -159,4 +160,28 @@ public class OssUtils {
 
         return null;
     }
+
+    /**
+     * 获取文件
+     * @param fileUrl
+     * @return
+     */
+    public InputStream getFile(String fileUrl) {
+
+        // 创建OSSClient实例。
+        OSS ossClient = new OSSClientBuilder().build(endPoint, accessKeyId, secretAccessKey);
+
+        try {
+            InputStream inputStream = ossClient.getObject(bucketName, "yqaa/2412/S256337789353984N-B20D9D3E-B0A5-4EE1-8F95-7CBE6AFDBED2.jpeg").getObjectContent();
+            log.info(ImageUtils.readImagePix(inputStream));
+            return inputStream;
+        } catch (Exception e) {
+            e.printStackTrace();
+            return null;
+        } finally {
+            if (ossClient != null) {
+                ossClient.shutdown();
+            }
+        }
+    }
 }