You need to sign in to do that
Don't have an account?
Rachit Joshi
Download multiple files as zip from ContentVersion
I found this link https://developer.salesforce.com/blogs/engineering/2014/04/building-content-rich-visualforce-pages-with-salesforce-crm-content.html to download multiple files as .zip from ContentVersion.
Can we use /sfc/servlet.shepherd/version/download/ to download multiple files?
Since this is not documented in any of the salesforce docs.
Can we use /sfc/servlet.shepherd/version/download/ to download multiple files?
Since this is not documented in any of the salesforce docs.
Sorry for this issue you are facing.
Download multiple ContentVersion files as Zip:
In our org, there is a related list underneath the Contract object of ContentVersions of the contract and any amendments. Users wanted to be able to download all (or download selected) files with one click.
Such relatedList does not provide any download button. You need to select each file in turn, go to the Content page and click Download. Tedious. Users hated it. I hated it.
Googling revealed an interesting post on downloading attachments into a zip http://www.valnavjo.com/blog/compressing-files-in-salesforce/ using JSZip. However, we had files greater than 15MB and I worried about Heap Limits.
Turns out SFDC provides download ContentVersion as zip already on the Content tab. (Where our users nor I almost never go as the Contract relatedList is more convenient). So, I used the browser developer Tools to see what URL was constructed by SFDC and saw that it exploited the undocumented servlet.shepherd.
The specific URL to use is: Where delimitedSelectedIdList is a list of ContentVersion ids separated by a 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 a single zip): Tested this on large zip files (~400 MB) and had no issues.
Notes:
Hope this helps.
Kindly mark this as solved if the reply was helpful so that it gets removed from the unanswered queue which results in helping others who are encountering a similar issue.
Thanks,
Nagendra