use of com.salesmanager.core.model.content.FileContentType in project shopizer by shopizer-ecommerce.
the class FilesController method downloadFile.
/**
* Serves static files (css, js ...) the repository is a single node by merchant
* @param storeCode
* @param extension
* @return
* @throws IOException
* @throws ServiceException
*/
@RequestMapping("/static/files/{storeCode}/{fileName}.{extension}")
@ResponseBody
public byte[] downloadFile(@PathVariable final String storeCode, @PathVariable final String fileName, @PathVariable final String extension, HttpServletRequest request, HttpServletResponse response) throws IOException, ServiceException {
// example -> /files/<store code>/myfile.css
FileContentType fileType = FileContentType.STATIC_FILE;
// needs to query the new API
OutputContentFile file = contentService.getContentFile(storeCode, fileType, new StringBuilder().append(fileName).append(".").append(extension).toString());
if (file != null) {
return file.getFile().toByteArray();
} else {
LOGGER.debug("File not found " + fileName + "." + extension);
response.sendError(404, Constants.FILE_NOT_FOUND);
return null;
}
}
Aggregations