Examples of EntryAttachment


Examples of com.apress.prospring3.springblog.domain.EntryAttachment

    Message message;

    if (file.getSize() > 0) {
      if (uploadType.equalsIgnoreCase("entry")) {
        // Construct Attachment object
        EntryAttachment entryAttachment = new EntryAttachment();
        entryAttachment.setFileName(getFileName(file));
        entryAttachment.setFileData(IOUtils.toByteArray(file.getInputStream()));
        entryAttachment.setContentType(file.getContentType());
       
        Entry entry = entryService.findById(blogId);
        entryAttachment.setEntry(entry);
        entry.addAttachment(entryAttachment);
        entryService.save(entry);
      } else {
        // Construct Attachment object
        CommentAttachment commentAttachment = new CommentAttachment();
View Full Code Here

Examples of com.apress.prospring3.springblog.domain.EntryAttachment

  @RequestMapping(value = "/entry/{id}", method=RequestMethod.GET, produces="application/force-download")
  @ResponseBody
  public byte[] downloadEntryAttachment(@PathVariable("id") Long id, HttpServletRequest request, HttpServletResponse response) {
    logger.info("Processing download for entry attachment with id {}", id);
   
    EntryAttachment attachment = entryAttachmentService.findById(id);
   
        response.setContentType(attachment.getContentType());
        response.setContentLength(attachment.getFileData().length);
        response.setHeader("Content-Disposition","attachment; filename=\"" + attachment.getFileName() +"\"");
   
    return attachment.getFileData();
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.