Examples of DownloadResource


Examples of org.exoplatform.download.DownloadResource

         {
            UIFormUploadInput input = uiForm.getChildById("name" + index);
            UploadResource uploadResource = input.getUploadResource();
            if (uploadResource != null)
            {
               DownloadResource dresource =
                  new InputStreamDownloadResource(input.getUploadDataAsStream(), uploadResource.getMimeType());
               dresource.setDownloadName(uploadResource.getFileName());
               downloadLink[index] = dservice.getDownloadLink(dservice.addDownloadResource(dresource));
               fileName[index] = uploadResource.getFileName();
               inputName[index] = "name" + index;
            }
         }
View Full Code Here

Examples of org.exoplatform.download.DownloadResource

            List<String> inputName = new ArrayList<String>();
            for (int index = 0; index <= 2; index++) {
                UIFormUploadInput input = uiForm.getChildById("name" + index);
                UploadResource uploadResource = input.getUploadResource();
                if (uploadResource != null) {
                    DownloadResource dresource = new InputStreamDownloadResource(input.getUploadDataAsStream(),
                            uploadResource.getMimeType());
                    dresource.setDownloadName(uploadResource.getFileName());
                    downloadLink.add(dservice.getDownloadLink(dservice.addDownloadResource(dresource)));
                    fileName.add(uploadResource.getFileName());
                    inputName.add("name" + index);
                }
            }

            for (int index = 3; index < 5; index++) {
                UIUploadInput input = uiForm.getChildById("name" + index);
                UploadResource[] uploadResources = input.getUploadResources();
                for (UploadResource uploadResource : uploadResources) {
                    DownloadResource dresource = new InputStreamDownloadResource(new FileInputStream(new File(
                            uploadResource.getStoreLocation())), uploadResource.getMimeType());
                    dresource.setDownloadName(uploadResource.getFileName());
                    downloadLink.add(dservice.getDownloadLink(dservice.addDownloadResource(dresource)));
                    fileName.add(uploadResource.getFileName());
                    inputName.add("name" + index);
                }
            }
View Full Code Here

Examples of org.exoplatform.download.DownloadResource

    public void execute(WebAppController controller, HttpServletRequest req, HttpServletResponse res) throws Exception {
        String resourceId = req.getParameter("resourceId");
        res.setHeader("Cache-Control", "private max-age=600, s-maxage=120");
        ExoContainer container = ExoContainerContext.getCurrentContainer();
        DownloadService dservice = (DownloadService) container.getComponentInstanceOfType(DownloadService.class);
        DownloadResource dresource = dservice.getDownloadResource(resourceId);
        if (dresource == null) {
            res.setContentType("text/plain");
            res.getWriter().write("NO DOWNDLOAD RESOURCE CONTENT  OR YOU DO NOT HAVE THE RIGHT TO ACCESS THE CONTENT");
            return;
        }
        String userAgent = req.getHeader("User-Agent");
        if (dresource.getDownloadName() != null) {
            if (userAgent != null && userAgent.contains("Firefox")) {
                res.setHeader("Content-Disposition",
                        "attachment; filename*=utf-8''" + URLEncoder.encode(dresource.getDownloadName(), "UTF-8") + "");
            } else {
                res.setHeader("Content-Disposition",
                        "attachment;filename=\"" + URLEncoder.encode(dresource.getDownloadName(), "UTF-8") + "\"");
            }
        }
        res.setContentType(dresource.getResourceMimeType());
        InputStream is = dresource.getInputStream();
        try {
            optimalRead(is, res.getOutputStream());
        } catch (Exception e) {
            log.error(e.getMessage(), e);
        } finally {
View Full Code Here

Examples of org.exoplatform.download.DownloadResource

   {
      String resourceId = req.getParameter("resourceId");
      res.setHeader("Cache-Control", "private max-age=600, s-maxage=120");
      ExoContainer container = ExoContainerContext.getCurrentContainer();
      DownloadService dservice = (DownloadService)container.getComponentInstanceOfType(DownloadService.class);
      DownloadResource dresource = dservice.getDownloadResource(resourceId);
      if (dresource == null)
      {
         res.setContentType("text/plain");
         res.getWriter().write("NO DOWNDLOAD RESOURCE CONTENT  OR YOU DO NOT HAVE THE RIGHT TO ACCESS THE CONTENT");
         return;
      }
      String userAgent = req.getHeader("User-Agent");
      if (dresource.getDownloadName() != null)
      {
         if (userAgent != null && userAgent.contains("Firefox"))
         {
            res.setHeader("Content-Disposition", "attachment; filename*=utf-8''"
               + URLEncoder.encode(dresource.getDownloadName(), "UTF-8") + "");
         }
         else
         {
            res.setHeader("Content-Disposition", "attachment;filename=\""
               + URLEncoder.encode(dresource.getDownloadName(), "UTF-8") + "\"");           
         }
      }
      res.setContentType(dresource.getResourceMimeType());
      InputStream is = dresource.getInputStream();
      try
      {
         optimalRead(is, res.getOutputStream());
      }
      catch (Exception ex)
View Full Code Here

Examples of org.exoplatform.download.DownloadResource

   public void execute(WebAppController controller, HttpServletRequest req, HttpServletResponse res) throws Exception
   {
      res.setHeader("Cache-Control", "private max-age=600, s-maxage=120");
      ExoContainer container = ExoContainerContext.getCurrentContainer();
      DownloadService dservice = (DownloadService)container.getComponentInstanceOfType(DownloadService.class);
      DownloadResource dresource = dservice.getDownloadResource(resourceId);
      if (dresource == null)
      {
         res.setContentType("text/plain");
         res.getWriter().write("NO DOWNDLOAD RESOURCE CONTENT  OR YOU DO NOT HAVE THE RIGHT TO ACCESS THE CONTENT");
         return;
      }
      String userAgent = req.getHeader("User-Agent");
      if (dresource.getDownloadName() != null)
      {
         if (userAgent != null && userAgent.contains("MSIE"))
         {
            res.setHeader("Content-Disposition", "attachment;filename=\""
               + URLEncoder.encode(dresource.getDownloadName(), "UTF-8") + "\"");
         }
         else
         {
            res.setHeader("Content-Disposition", "attachment; filename*=utf-8''"
               + URLEncoder.encode(dresource.getDownloadName(), "UTF-8") + "");
         }
      }
      res.setContentType(dresource.getResourceMimeType());
      InputStream is = dresource.getInputStream();
      try
      {
         optimalRead(is, res.getOutputStream());
      }
      catch (Exception ex)
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.