|
@@ -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);
|