|
@@ -2,6 +2,8 @@ package com.fdkankan.fyun.http;
|
|
|
|
|
|
import cn.hutool.core.io.FileUtil;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.fdkankan.common.constant.ErrorCode;
|
|
|
+import com.fdkankan.common.exception.BusinessException;
|
|
|
import com.fdkankan.common.util.FileUtils;
|
|
|
import com.fdkankan.fyun.face.AbstractFYunFileService;
|
|
|
import com.fdkankan.fyun.http.config.HttpFyunConfig;
|
|
@@ -294,7 +296,31 @@ public class HttpFileService extends AbstractFYunFileService {
|
|
|
|
|
|
@Override
|
|
|
public List<String> listRemoteFiles(String bucket, String sourcePath) {
|
|
|
- throw new UnsupportedOperationException("不支持列举文件列表!");
|
|
|
+ try {
|
|
|
+
|
|
|
+ log.info("list files under path,bucket:{},sourcePath:{}", bucket, sourcePath);
|
|
|
+
|
|
|
+ Map<String, Object> params = new HashMap<>();
|
|
|
+ params.put("appName", fYunFileConfig.getKey());
|
|
|
+ params.put("secret", fYunFileConfig.getSecret());
|
|
|
+
|
|
|
+ params.put("targetDir", sourcePath);
|
|
|
+ String url = fYunFileConfig.getEndPoint() + httpFyunConfig.getListDir();
|
|
|
+
|
|
|
+ log.info("url:{},params:{}", url, JSONObject.toJSONString(params));
|
|
|
+
|
|
|
+ ResponseEntity<Result> responseEntity = restTemplate.postForEntity(url, params, Result.class);
|
|
|
+ log.info("Fyun Http Utils list dir,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 list dir failed!");
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_3002);
|
|
|
+ }
|
|
|
+ log.info("文件列举成功,path:{}", sourcePath);
|
|
|
+ return JSONObject.parseArray(JSONObject.toJSONString(responseEntity.getBody()),String.class);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("列举文件目录失败,key=" + sourcePath, e);
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_3002);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|