Commit 16f7e25e authored by 张辰's avatar 张辰

加上tmpDir

parent b56e5067
...@@ -73,8 +73,10 @@ import org.springframework.util.LinkedMultiValueMap; ...@@ -73,8 +73,10 @@ import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap; import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
import javax.annotation.PostConstruct;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.io.File; import java.io.File;
import java.io.IOException;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -132,6 +134,15 @@ public class ThemeManager { ...@@ -132,6 +134,15 @@ public class ThemeManager {
@Resource @Resource
private RestTemplate restTemplate; private RestTemplate restTemplate;
@PostConstruct
public void init() throws IOException {
File f = new File(tmpDir);
log.info("create directory {}", tmpDir);
if (!f.exists()) {
FileUtils.forceMkdir(f);
}
}
// 专栏 // 专栏
@Autowired @Autowired
private FeignClientForCommunity feignClientForCommunity; private FeignClientForCommunity feignClientForCommunity;
...@@ -276,7 +287,7 @@ public class ThemeManager { ...@@ -276,7 +287,7 @@ public class ThemeManager {
String imgUrl = img.getRemark(); String imgUrl = img.getRemark();
String[] arr = StringUtils.split(imgUrl, "."); String[] arr = StringUtils.split(imgUrl, ".");
String suffix = arr[arr.length - 1]; String suffix = arr[arr.length - 1];
String fileName = imgUrl.substring(imgUrl.lastIndexOf('/') + 1); String fileName = tmpDir + imgUrl.substring(imgUrl.lastIndexOf('/') + 1);
ResponseEntity<byte[]> resp = restTemplate.getForEntity(img.getRemark(), byte[].class); ResponseEntity<byte[]> resp = restTemplate.getForEntity(img.getRemark(), byte[].class);
byte[] rst = resp.getBody(); byte[] rst = resp.getBody();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment