Browse Source

修改获取文件内容方法

tianboguang 2 years ago
parent
commit
2dfc500419

+ 11 - 6
4dkankan-utils-fyun-https/src/main/java/com/fdkankan/fyun/http/HttpFileService.java

@@ -9,6 +9,7 @@ import com.fdkankan.fyun.http.entity.Result;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
 import org.springframework.http.HttpStatus;
 import org.springframework.http.ResponseEntity;
@@ -35,6 +36,9 @@ public class HttpFileService extends AbstractFYunFileService {
     @Autowired
     private HttpFyunConfig httpFyunConfig;
 
+    @Value("${nas.dir.base:/mnt}")
+    private String nasBasePath;
+
     @Override
     public String uploadFile(String bucket, byte[] data, String remoteFilePath) {
         try {
@@ -240,11 +244,12 @@ public class HttpFileService extends AbstractFYunFileService {
     @Override
     public String getFileContent(String bucketName, String remoteFilePath) {
         try {
+            log.info("获取文件内容:{}",remoteFilePath);
             // 先将文件下载到本地
             String fileName = remoteFilePath.substring(remoteFilePath.lastIndexOf("/")+1);
             downloadFile(remoteFilePath, httpFyunConfig.getLocalTempPath() + fileName);
-            String content =FileUtils.readFile(httpFyunConfig.getLocalTempPath() + fileName);
-            FileUtils.deleteFile(httpFyunConfig.getLocalTempPath() + fileName);
+            String content =FileUtils.readFile(nasBasePath + httpFyunConfig.getLocalTempPath() + fileName);
+            FileUtils.deleteFile(nasBasePath + httpFyunConfig.getLocalTempPath() + fileName);
             return content;
         } catch (Exception e) {
             log.error("获取文件内容失败:{}", remoteFilePath);
@@ -261,9 +266,9 @@ public class HttpFileService extends AbstractFYunFileService {
             params.put("fileName", objectName);
             String url = fYunFileConfig.getEndPoint() + httpFyunConfig.getFileExist();
             ResponseEntity<Result> responseEntity = restTemplate.postForEntity(url, params, Result.class);
-            log.info("Fyun Http Utils file exist,url:{},params:{},结果,{}", url, JSONObject.toJSONString(params), JSONObject.toJSONString(responseEntity.getBody()));
+            log.info("Fyun Http Utils check file exist,url:{},params:{},结果,{}", url, JSONObject.toJSONString(params), JSONObject.toJSONString(responseEntity.getBody()));
             if (responseEntity.getStatusCode() != HttpStatus.OK || responseEntity.getBody().getCode() != Result.CODE_SUCCESS) {
-                log.error("Fyun Http Utils copy file failed!");
+                log.error("Fyun Http Utils check file exist failed!");
             }
             return Boolean.parseBoolean(responseEntity.getBody().getData().toString());
         } catch (Exception e) {
@@ -291,9 +296,9 @@ public class HttpFileService extends AbstractFYunFileService {
             params.put("targetPath", localPath);
             String url = fYunFileConfig.getEndPoint() + httpFyunConfig.getDownloadFile();
             ResponseEntity<Result> responseEntity = restTemplate.postForEntity(url, params, Result.class);
-            log.info("Fyun Http Utils file exist,url:{},params:{},结果,{}", url, JSONObject.toJSONString(params), JSONObject.toJSONString(responseEntity.getBody()));
+            log.info("Fyun Http Utils download file,url:{},params:{},结果,{}", url, JSONObject.toJSONString(params), JSONObject.toJSONString(responseEntity.getBody()));
             if (responseEntity.getStatusCode() != HttpStatus.OK || responseEntity.getBody().getCode() != Result.CODE_SUCCESS) {
-                log.error("Fyun Http Utils copy file failed!");
+                log.error("Fyun Http Utils download file failed!");
             }
         } catch (Throwable throwable) {
             log.error("文件下载失败:{}", remoteFilePath);

+ 1 - 1
4dkankan-utils-model/src/main/java/com/fdkankan/model/constants/ConstantFilePath.java

@@ -43,7 +43,7 @@ public class ConstantFilePath {
     public static final String ALI_QRCODE_FOLDER = "/mnt/4Dkankan/alicode/";
     public static final String WEIXIN_QRCODE_FOLDER = "/mnt/4Dkankan/weixincode/";
 
-    public static final String OSS_PREFIX = "home/";
+    public static final String OSS_PREFIX = "/home/";
 
     /**
      * 场景数据文件路径

+ 0 - 5
4dkankan-utils-redis/pom.xml

@@ -39,11 +39,6 @@
             <groupId>org.apache.commons</groupId>
             <artifactId>commons-pool2</artifactId>
         </dependency>
-        <dependency>
-            <groupId>org.redisson</groupId>
-            <artifactId>redisson</artifactId>
-            <version>3.8.2</version>
-        </dependency>
     </dependencies>
 
 

+ 0 - 32
4dkankan-utils-redis/src/main/java/com/fdkankan/redis/config/RedisConfig.java

@@ -1,12 +1,5 @@
 package com.fdkankan.redis.config;
 
-
-import org.apache.commons.lang3.StringUtils;
-import org.redisson.Redisson;
-import org.redisson.api.RedissonClient;
-import org.redisson.config.Config;
-import org.redisson.config.SingleServerConfig;
-import org.springframework.beans.factory.annotation.Value;
 import org.springframework.boot.autoconfigure.AutoConfigureAfter;
 import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration;
 import org.springframework.context.annotation.Bean;
@@ -19,31 +12,6 @@ import org.springframework.data.redis.serializer.StringRedisSerializer;
 @AutoConfigureAfter(RedisAutoConfiguration.class)
 public class RedisConfig {
 
-    @Value("${spring.redis.host}")
-    private String host;
-
-    @Value("${spring.redis.port}")
-    private String port;
-
-    @Value("${spring.redis.database:0}")
-    private int database;
-
-    @Value("${spring.redis.password:#{null}}")
-    private String password;
-
-    @Bean
-    public RedissonClient redissonClient() {
-        Config config = new Config();
-        SingleServerConfig singleServerConfig = config.useSingleServer();
-        singleServerConfig.setAddress("redis://".concat(host).concat(":").concat(port));
-        if (StringUtils.isNotEmpty(password)) {
-            singleServerConfig.setPassword(password);
-        }
-        singleServerConfig.setDatabase(database);
-        return Redisson.create(config);
-
-    }
-
     @Bean
     public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory redisConnectionFactory) {
         RedisTemplate template = new RedisTemplate();

+ 0 - 33
4dkankan-utils-redis/src/main/java/com/fdkankan/redis/util/RedisBloomUtils.java

@@ -1,33 +0,0 @@
-package com.fdkankan.redis.util;
-
-import org.redisson.api.RBloomFilter;
-import org.redisson.api.RedissonClient;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-@Component
-public class RedisBloomUtils {
-
-    @Autowired
-    private RedissonClient redissonClient;
-
-    public void add(String key,String value){
-        RBloomFilter<Object> bloomFilter = redissonClient.getBloomFilter(key);
-        bloomFilter.tryInit(500000,0.01);
-        bloomFilter.add(value);
-    }
-
-    public boolean contains(String key,String value){
-        RBloomFilter<Object> bloomFilter = redissonClient.getBloomFilter(key);
-        bloomFilter.tryInit(500000,0.01);
-        return bloomFilter.contains(value);
-    }
-
-    public void delete(String key){
-        RBloomFilter<Object> bloomFilter = redissonClient.getBloomFilter(key);
-        bloomFilter.tryInit(500000,0.01);
-        bloomFilter.delete();
-    }
-
-
-}