ソースを参照

添加解密逻辑

tianboguang 2 年 前
コミット
35678bd7ed

+ 6 - 0
pom.xml

@@ -134,6 +134,12 @@
       <version>3.0.0-SNAPSHOT</version>
     </dependency>
 
+    <dependency>
+      <groupId>net.lingala.zip4j</groupId>
+      <artifactId>zip4j</artifactId>
+      <version>1.3.2</version>
+    </dependency>
+
   </dependencies>
   <build>
     <plugins>

+ 10 - 1
src/main/java/com/fdkankan/contro/controller/SceneFileController.java

@@ -16,6 +16,7 @@ import com.fdkankan.redis.util.RedisLockUtil;
 import com.fdkankan.redis.util.RedisUtil;
 import com.fdkankan.web.response.ResultData;
 import lombok.extern.log4j.Log4j2;
+import net.lingala.zip4j.core.ZipFile;
 import org.apache.commons.lang3.ObjectUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
@@ -95,7 +96,15 @@ public class SceneFileController{
         log.info("dataSource 为:{}", dataSource);
 
         // 解压资源文件上传
-        ZipUtil.unzip(filePath.concat(zipFileName),filePath);
+        ZipFile zipFile = new ZipFile(new File(filePath.concat(zipFileName)));
+        if (zipFile.isEncrypted()) {
+            String pwd = zipFileName.substring(0, 5).concat(zipFileName.substring(0, 5));
+            zipFile.setPassword(pwd);
+            zipFile.extractAll(filePath);
+        } else {
+            ZipUtil.unzip(filePath.concat(zipFileName), filePath);
+        }
+
 
         // 上传oaas
         fYunFileService.uploadFileByCommand(filePath.concat(folderName), ConstantFilePath.OSS_PREFIX.concat(subFolder));