title: How to download multiple files as a zip-file using Liferay?
body: <h3>Problem Statement</h3>
  
  <p>I am using the "multiple file download" function in the documents and media portlet inside the Liferay platform.  However, it downloads all the files separately.  </p>
  
  <p>I am using Liferay 6.1 .</p>
  
  <h3>Question</h3>
  
  <p>I would like to modify the functionality so that when I select multiple files and click the download function it downloads all those files as one single zip file.  Is this possible?  If so how would something like this be achieved?</p>
  
  <h3>Update</h3>
  
  <p>I tryed to deploy a liferay-hook but i got BUILD FAILED.</p>
  
  <p>source :</p>
  
  <p><a href="http://www.surekhatech.com/blog/multiple-file-download-for-liferay-documents-and-media-display-portlet" rel="nofollow noreferrer">http://www.surekhatech.com/blog/multiple-file-download-for-liferay-documents-and-media-display-portlet</a></p>
  
  <p>I don't want to override the documents-and-media-display-portlet of liferay.</p>
  
  <p>I'm trying to  copy paste code from project of blog. I have problem with my view.jsp .</p>
  
  <p>what I should take from source code and add in my view?</p>
  
  <p>My view.jsp:</p>
  
  <pre><code>&lt;c:choose&gt;
      &lt;c:when test="${fn:length(listFiles) gt 0}"&gt;
          &lt;div class="lfr-search-container " id="flash-table"&gt; 
              &lt;% 
                  PortletURL actionURL = renderResponse.createRenderURL(); 
                  List&lt;DLFileEntry&gt; list = (List&lt;DLFileEntry&gt;) request.getAttribute("listFiles");
                  DateFormat dateFormat = new SimpleDateFormat("MMM yyyy");
  
                  OrderByComparator orderByComparator = OrderByComparatorFactoryUtil.create("DLFileEntry", "modifiedDate", false);
                  Collections.sort(list,orderByComparator);
              %&gt;
              &lt;liferay-ui:search-container iteratorURL="&lt;%= actionURL %&gt;" delta="10" emptyResultsMessage="no-documents"&gt;
                  &lt;liferay-ui:search-container-results total="&lt;%= list.size() %&gt;" results="&lt;%= ListUtil.subList(list, searchContainer.getStart(), searchContainer.getEnd()) %&gt;" /&gt;
                  &lt;liferay-ui:search-container-row modelVar="file" className="DLFileEntry"&gt;
                      &lt;%
                          ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);
                          String pdfUrl = "", excelUrl = "";
                          String logo ="", vendor="", technology="", productType="", flashType="";
  
                          long globalGroupId = GroupLocalServiceUtil.getCompanyGroup(PortalUtil.getDefaultCompanyId()).getGroupId();
  
                          if(file.getExtension().equalsIgnoreCase("pdf"))
                              pdfUrl = "&lt;a target='_blank' href='"+ themeDisplay.getPortalURL() + themeDisplay.getPathContext() + "/documents/" + globalGroupId + StringPool.SLASH + file.getUuid()+"' &gt;&lt;img src='/flash-table-portlet/images/pdf.png' width='20px'/&gt; &lt;/a&gt;";
                          else if(file.getExtension().equalsIgnoreCase("xlsx") || file.getExtension().equalsIgnoreCase("xls") || file.getExtension().equalsIgnoreCase("csv") )
                              excelUrl = "&lt;a target='_blank' href='"+ themeDisplay.getPortalURL() + themeDisplay.getPathContext() + "/documents/" + globalGroupId + StringPool.SLASH + file.getUuid()+"' &gt;&lt;img src='/flash-table-portlet/images/excel.png' width='20px'/&gt; &lt;/a&gt;";
  
                          try{
                              Map&lt;String, Fields&gt; fieldsMap = file.getFieldsMap(file.getFileVersion().getFileVersionId());
                              for (Fields fields : fieldsMap.values()) {
                                  vendor =  fields.get("vendor").getValue().toString().replace("[\"", "").replace("\"]", "");
                                  if(vendor.equalsIgnoreCase("other"))
                                      logo="&lt;strong&gt;other&lt;/strong&gt;";
                                  else
                                      logo = "&lt;img src='/flash-table-portlet/images/vendor/"+vendor.toLowerCase()+".gif' style='max-width:120px' /&gt;";
                                  technology= fields.get("technology").getValue().toString().replace("[\"", "").replace("\"]", "");
                                  productType =  fields.get("producttype").getValue().toString().replace("[\"", "").replace("\"]", "");
                                  flashType =  fields.get("flashtype").getValue().toString().replace("[\"", "").replace("\"]", "");
                              }
                          }catch(Exception ex){
                              ex.printStackTrace();
                          }
                      %&gt;
                      &lt;liferay-ui:input-checkbox param="&lt;%= file.getName() %&gt;" cssClass="check"&gt;&lt;/liferay-ui:input-checkbox&gt;
                      &lt;liferay-ui:search-container-column-text name='date' cssClass="txt-capitalize width-10" value="&lt;%= dateFormat.format(file.getModifiedDate()) %&gt;" /&gt;
                      &lt;liferay-ui:search-container-column-text name='vendor' cssClass="width-10" value="&lt;%= logo %&gt;" /&gt;
                      &lt;liferay-ui:search-container-column-text name='technology' cssClass="width-10" value="&lt;%= technology %&gt;" /&gt;
                      &lt;liferay-ui:search-container-column-text name='product-type' cssClass="width-12"  value="&lt;%= productType %&gt;" /&gt;
                      &lt;liferay-ui:search-container-column-text name='flash-type' cssClass="width-12"  value="&lt;%= flashType %&gt;" /&gt;
                      &lt;liferay-ui:search-container-column-text name='model' cssClass="width-25"  value="&lt;%= file.getTitle() %&gt;" /&gt;
                      &lt;liferay-ui:search-container-column-text name='executive-summary' cssClass="width-10" value="&lt;%= pdfUrl %&gt;" /&gt;
                      &lt;liferay-ui:search-container-column-text name='excel-file' cssClass="width-10" value="&lt;%= excelUrl %&gt;" /&gt;
  
                      &lt;script type="text/javascript"&gt;
                      $('.check').click(function() {
                      &lt;%! List&lt;String&gt; multi_files_urls; %&gt;
                      $(".check").each(function(){
                          if($(this).is(":checked")){
                          &lt;%
                          FileEntry fileEntry = DLAppServiceUtil.getFileEntry(file.getFileEntryId());
                          FileVersion fileVersion = fileEntry.getFileVersion();
                          String queryString = "";
                          boolean appendFileEntryVersion = true;
                          boolean useAbsoluteURL = true;
                          String dlURL = DLUtil.getPreviewURL(fileEntry, fileVersion, themeDisplay, queryString, appendFileEntryVersion, useAbsoluteURL);
                          multi_files_urls.add(dlURL); 
                          %&gt;
                        }
                      });
                      &lt;/script&gt;
                  &lt;/liferay-ui:search-container-row&gt;
                  &lt;liferay-ui:search-iterator searchContainer="&lt;%= searchContainer %&gt;" paginate="${fn:length(listFiles) ge 10}" /&gt;
              &lt;/liferay-ui:search-container&gt;
          &lt;/div&gt;&lt;br /&gt;&lt;br /&gt;
  
  
      &lt;/c:when&gt;
      &lt;c:otherwise&gt;
          &lt;div class="alert alert-warning text-center"&gt;
              &lt;br /&gt;&lt;liferay-ui:message key="no-documents"/&gt;&lt;br /&gt;&lt;br /&gt;
          &lt;/div&gt;
      &lt;/c:otherwise&gt;
  &lt;/c:choose&gt;
  </code></pre>