We would like to allow a user to download an archive of files, which are stored as ContentDocuments.

We tried Zippex, but ran into CPU governor limits when the file count started to get above 10.

We tried getting these files to the client side to maybe use a javascript library, but ran into issues with the blob sizes.

Are there any ideas out there for alternative ways for a user to download/receive an archive of 10+ files? It can be zip, or any other way where they dont have to download them one-by-one.

If it matters, we are using custom Lightning Components on a Napili Customer Community.

  • 1
    "...ran into issues with the blob sizes." Trying to transport all 10+ files to the client at once? One at a time? Are you trying to transport files that are simply too large? – sfdcfox Oct 5 '17 at 22:31
  • Another approach may be 3rd party endpoint that is called from your VF/Lighting component, authorize to SF, grab files from there using REST API, compress them and return as zip – kurunve Oct 6 '17 at 6:49

Great answer was found here: http://cropredysfdc.com/2016/03/16/download-multiple-contentversion-files-as-zip/

This worked for me, and I hope others find it useful. We were already using <img src="{!'/sfc/servlet.shepherd/version/download/'+ id}" /> for individual fine downloads. All that need to be done to make it a zip of multiple documents is to append all of the other IDs, using '/' as a seperator

The specific URL to use is:

1 {!URLFOR('/sfc/servlet.shepherd/version/download/' & delimitedSelectedIdList &'?')} where delimitedSelectedIdList is a list of ContentVersion ids separated by forward slash. from my understanding, the ids separated by slashes is a sometimes-used REST convention to specify a list of resources.

Example (downloads 2 files into single zip)

1 {!URLFOR('/sfc/servlet.shepherd/version/download/068xxxxxxxxxxxxxxx/068yyyyyyyyyyyyyyy?')} I tested this on large zip files (~400 MB) and had no issues.

  • 3
    Thanks for the answer. Would you know how to rename to Zip on download ? I am able to download the zip file with the way you suggested. I also need to rename the zip folder. The Zip folder always has a name "downloaded-content". So I need to change this name to "xyz.zip". I also asked this question. stackoverflow.com/questions/49748741/… – aniltilanthe Apr 10 '18 at 8:54
  • Is this /sfc/servlet.shepherd/version/download/ officially supported by salesforce for use in Lightning?? I know its been mentioned in the salesforce blog for visualforce, but that was pre lightning. – rna7 Aug 22 '18 at 11:27
  • Hi @aniltilanthe Did you find the way to rename this downloaded zip? Let me know, please. I am stuck in same – Vivek Makkar Mar 11 '20 at 8:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.