if(wf == null) {
resp.sendError(404);
return;
}
log.finer("looking up file:" + fileName + " with parent:" + wf);
WebdavFile file = ofy.query(WebdavFile.class).filter("parent", wf).filter("name", fileName).get();
if(file == null) {
resp.sendError(404);
return;
}
log.fine("Sending file:" + fileName);
String contentType = file.getContentType();
String name = file.getName();
resp.setContentType(contentType);
//return images inline... by skipping this
if (contentType == null || !contentType.toLowerCase().startsWith("image"))
resp.setHeader("Content-Disposition", "attachment; filename=\"" + name + "\"");
//TODO add cache headers.
resp.getOutputStream().write(ofy.get(file.getData()).getData());
resp.flushBuffer();
}