|
@ -42,8 +42,10 @@ public class FastDFSController extends EnvelopRestEndpoint {
|
|
|
@Autowired
|
|
|
private FileResourceService fileResourceService;
|
|
|
|
|
|
@Value("${img.path}")
|
|
|
private String img_path;
|
|
|
@Value("${img.path1}")
|
|
|
private String img_path1;
|
|
|
@Value("${img.path2}")
|
|
|
private String img_path2;
|
|
|
|
|
|
/**
|
|
|
* 文件上传 - 返回相关索引信息
|
|
@ -187,7 +189,7 @@ public class FastDFSController extends EnvelopRestEndpoint {
|
|
|
@ApiParam(name = "id", value = "id", required = true)
|
|
|
@RequestParam(value = "id") String id) throws Exception {
|
|
|
FileResource fileResource = fileResourceService.findById(id);
|
|
|
String storagePath = fileResource.getStoragePath();
|
|
|
String storagePath = img_path1+fileResource.getStoragePath();
|
|
|
byte[] bytes = load(storagePath);
|
|
|
String fileStream = new String(Base64.getEncoder().encode(bytes));
|
|
|
if (!StringUtils.isEmpty(fileStream)) {
|
|
@ -208,9 +210,9 @@ public class FastDFSController extends EnvelopRestEndpoint {
|
|
|
public Envelop downloadByPath(
|
|
|
@ApiParam(name = "path", value = "文件路径", required = true)
|
|
|
@RequestParam(value = "path") String path) throws Exception {
|
|
|
if (path.split(":").length < 2) {
|
|
|
return failed("参数有误");
|
|
|
}
|
|
|
// if (path.split(":").length < 2) {
|
|
|
// return failed("参数有误");
|
|
|
// }
|
|
|
byte[] bytes = load(path);
|
|
|
String fileStream = new String(Base64.getEncoder().encode(bytes));
|
|
|
if (!StringUtils.isEmpty(fileStream)) {
|
|
@ -227,10 +229,10 @@ public class FastDFSController extends EnvelopRestEndpoint {
|
|
|
*/
|
|
|
public String upload(InputStream inputStream, String fileName) {
|
|
|
OutputStream outputStream = null;
|
|
|
String path1 = img_path + "/" + fileName;
|
|
|
String path1 = img_path1+img_path2 + "/" + fileName;
|
|
|
try {
|
|
|
//文件源
|
|
|
File files = new File(img_path);
|
|
|
File files = new File(img_path1+img_path2);
|
|
|
if (!files.exists()) {//判断文件夹是否创建,没有创建则创建新文件夹
|
|
|
files.mkdirs();
|
|
|
}
|
|
@ -257,7 +259,7 @@ public class FastDFSController extends EnvelopRestEndpoint {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
return path1;
|
|
|
return img_path2 + "/" + fileName;
|
|
|
}
|
|
|
|
|
|
/**
|