|
26 | 26 | import javax.servlet.http.HttpServletRequest;
|
27 | 27 | import javax.servlet.http.HttpServletResponse;
|
28 | 28 |
|
| 29 | +import org.springframework.beans.factory.annotation.Autowired; |
29 | 30 | import org.springframework.beans.factory.annotation.Value;
|
30 | 31 | import org.springframework.boot.context.properties.ConfigurationProperties;
|
| 32 | +import org.springframework.core.io.Resource; |
| 33 | +import org.springframework.core.io.ResourceLoader; |
31 | 34 | import org.springframework.stereotype.Controller;
|
32 | 35 | import org.springframework.util.FileCopyUtils;
|
33 | 36 | import org.springframework.web.bind.annotation.RequestMapping;
|
34 | 37 | import org.springframework.web.bind.annotation.RequestMethod;
|
35 | 38 | import org.springframework.web.bind.annotation.ResponseBody;
|
| 39 | + |
| 40 | +import com.sun.glass.ui.Application; |
| 41 | + |
36 | 42 | import org.springframework.web.bind.annotation.RequestBody;
|
37 | 43 |
|
38 | 44 |
|
39 | 45 | @Controller
|
40 | 46 | public class SubscriptionFilesController {
|
41 | 47 |
|
| 48 | + @Autowired |
| 49 | + private ResourceLoader resourceLoader; |
| 50 | + |
42 | 51 | @Value("${ei.subscriptionFilePath}") private String subscriptionFilePath;
|
43 | 52 | private static final String APPLICATION_JSON = "application/json";
|
44 | 53 |
|
45 | 54 |
|
46 | 55 | @RequestMapping(value = "/download/subscriptiontemplate", method = RequestMethod.GET, produces = APPLICATION_JSON)
|
47 | 56 | public @ResponseBody void getSubscriptionJsonTemplate(HttpServletResponse response) throws IOException {
|
48 |
| - File file = getFile(subscriptionFilePath); |
49 |
| - InputStream in = new FileInputStream(file); |
50 | 57 |
|
| 58 | + Resource resource = resourceLoader.getResource("classpath:" + subscriptionFilePath); |
| 59 | + File file = resource.getFile(); |
| 60 | + InputStream in = new FileInputStream(file); |
| 61 | + |
51 | 62 | response.setContentType(APPLICATION_JSON);
|
52 | 63 | response.setHeader("Content-Disposition", "attachment; filename=" + file.getName());
|
53 | 64 | response.setHeader("Content-Length", String.valueOf(file.length()));
|
|
0 commit comments