|
@ -46,8 +46,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;
|
|
|
|
|
|
private final ResourceLoader resourceLoader;
|
|
|
|
|
@ -199,7 +201,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)) {
|
|
@ -220,9 +222,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)) {
|
|
@ -239,10 +241,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();
|
|
|
}
|
|
@ -269,7 +271,7 @@ public class FastDFSController extends EnvelopRestEndpoint {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
return path1;
|
|
|
return img_path2 + "/" + fileName;
|
|
|
}
|
|
|
|
|
|
/**
|