use of org.datavec.api.util.ClassPathResource in project deeplearning4j by deeplearning4j.
the class Assets method apply.
@Override
public Result apply(String s) {
String fullPath = assetsRootDirectory + s;
InputStream inputStream;
try {
inputStream = new ClassPathResource(fullPath).getInputStream();
} catch (Exception e) {
log.debug("Could not find asset: {}", s);
return ok();
} catch (Throwable t) {
return ok();
}
String fileName = FilenameUtils.getName(fullPath);
response().setHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + fileName + "\"");
scala.Option<String> contentType = MimeTypes.forFileName(fileName);
String ct;
if (contentType.isDefined()) {
ct = contentType.get();
} else {
ct = "application/octet-stream";
}
return ok(inputStream).as(ct);
}
Aggregations