@Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { String attachmentId = req.getParameter("attachment"); String timelineItemId = req.getParameter("timelineItem"); if (attachmentId == null || timelineItemId == null) { LOG.warning("attempted to load image attachment with missing IDs"); resp.sendError(400); } // identify the viewing user Credential credential = AuthUtil.getCredential(req); // Get the content type String contentType = MirrorClient.getAttachmentContentType(credential, timelineItemId, attachmentId); // Get the attachment bytes InputStream attachmentInputStream = MirrorClient.getAttachmentInputStream(credential, timelineItemId, attachmentId); // Write it out resp.setContentType(contentType); ByteStreams.copy(attachmentInputStream, resp.getOutputStream()); }