|
@@ -18,17 +18,18 @@ import java.nio.file.Paths;
|
|
@RequestMapping("/ros")
|
|
@RequestMapping("/ros")
|
|
public class RosController {
|
|
public class RosController {
|
|
|
|
|
|
- @Autowired
|
|
|
|
- private ResourceLoader resourceLoader;
|
|
|
|
|
|
+// @Autowired
|
|
|
|
+// private ResourceLoader resourceLoader;
|
|
|
|
|
|
@GetMapping("/config")
|
|
@GetMapping("/config")
|
|
- public void download(HttpServletResponse response, @RequestParam("fileName") String fileName) {
|
|
|
|
|
|
+ public void config(HttpServletResponse response) {
|
|
try {
|
|
try {
|
|
response.setContentType("application/octet-stream;charset=utf-8");
|
|
response.setContentType("application/octet-stream;charset=utf-8");
|
|
- response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, "utf-8"));
|
|
|
|
|
|
+ response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("config.yaml", "utf-8"));
|
|
byte[] buffer = new byte[1024];
|
|
byte[] buffer = new byte[1024];
|
|
- org.springframework.core.io.Resource resource = resourceLoader.getResource("classpath:your-file.txt");
|
|
|
|
- InputStream inputStream = resource.getInputStream();
|
|
|
|
|
|
+// org.springframework.core.io.Resource resource = resourceLoader.getResource("classpath:config.yaml");
|
|
|
|
+// InputStream inputStream = resource.getInputStream();
|
|
|
|
+ InputStream inputStream = Files.newInputStream(Paths.get("/mnt/disk001/oss-config/yaml/config.yaml"));
|
|
ServletOutputStream outputStream = response.getOutputStream();
|
|
ServletOutputStream outputStream = response.getOutputStream();
|
|
for (int bytesRead = inputStream.read(buffer); bytesRead >= 0; bytesRead = inputStream.read(buffer)) {
|
|
for (int bytesRead = inputStream.read(buffer); bytesRead >= 0; bytesRead = inputStream.read(buffer)) {
|
|
outputStream.write(buffer, 0, bytesRead);
|
|
outputStream.write(buffer, 0, bytesRead);
|