修改远程方法调用:RemoteFileService 增加:删除、获取服务器容量、加签三个方法

pull/84/head
duandazhi 4 years ago
parent f412996375
commit 938fc7d088

@ -2,7 +2,9 @@ package com.ruoyi.system.api;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;
import com.ruoyi.common.core.constant.ServiceNameConstants;
@ -25,5 +27,26 @@ public interface RemoteFileService
* @return
*/
@PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
public R<SysFile> upload(@RequestPart(value = "file") MultipartFile file);
R<SysFile> upload(@RequestPart(value = "file") MultipartFile file);
/**
*
* url
*/
@PostMapping("delete")
R<Boolean> delete(@RequestParam("fileUrl") String fileUrl);
/**
*
*
*/
@GetMapping("objectsCapacityStr")
R<String> capacityStr();
/**
* url; url,url
* @param fileUrl url
*/
@GetMapping("getPresignedUrl")
R<String> getPresignedUrl(@RequestParam(value = "fileUrl") String fileUrl);
}

@ -30,6 +30,21 @@ public class RemoteFileFallbackFactory implements FallbackFactory<RemoteFileServ
{
return R.fail("上传文件失败:" + throwable.getMessage());
}
@Override
public R<Boolean> delete(String fileUrl) {
return R.fail("删除文件失败:" + throwable.getMessage());
}
@Override
public R<String> capacityStr() {
return R.fail("文件容量获取失败:" + throwable.getMessage());
}
@Override
public R<String> getPresignedUrl(String fileUrl) {
return R.fail("文件加签失败:" + throwable.getMessage());
}
};
}
}

@ -24,7 +24,7 @@ public class FtpConfig {
* eg1: www.ourslook.com
* eg2: 192.168.0.1
*/
private String hostName;
private String endpoint;
/**
* ftp21
*/
@ -52,12 +52,12 @@ public class FtpConfig {
*/
private String domain;
public String getHostName() {
return hostName;
public String getEndpoint() {
return endpoint;
}
public void setHostName(String hostName) {
this.hostName = hostName;
public void setEndpoint(String endpoint) {
this.endpoint = endpoint;
}
public Integer getPort() {

@ -6,7 +6,6 @@ import com.ruoyi.common.core.exception.CustomException;
import com.ruoyi.file.config.FtpConfig;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
@ -37,7 +36,7 @@ public class FtpFileServiceImpl implements IDfsService {
Ftp ftp = null;
try {
ftp = new Ftp(ftpConfig.getHostName(), ftpConfig.getPort(), ftpConfig.getUserName(), ftpConfig.getPassword());
ftp = new Ftp(ftpConfig.getEndpoint(), ftpConfig.getPort(), ftpConfig.getUserName(), ftpConfig.getPassword());
ftp.setBackToPwd(true);
ftp.cd("/");
// 主要是主动模式还是被动
@ -56,7 +55,7 @@ public class FtpFileServiceImpl implements IDfsService {
public boolean deleteFile(String fileUrl) {
Ftp ftp = null;
try {
ftp = new Ftp(ftpConfig.getHostName(), ftpConfig.getPort(), ftpConfig.getUserName(), ftpConfig.getPassword());
ftp = new Ftp(ftpConfig.getEndpoint(), ftpConfig.getPort(), ftpConfig.getUserName(), ftpConfig.getPassword());
// 主要是主动模式还是被动
ftp.setMode(FtpMode.Active);
String storePath = getStorePath(fileUrl);

Loading…
Cancel
Save