Download Multiple Files from Libraries
Consider a scenario in which we are supposed to download all files from libraries. Below are different approaches which can be utilized:
Approach 1: Salesforce UI Download Button
If the file size is around 60 or less in the library then you can use Salesforce UI to download all files at one time.
Open any library, click on the show all button, then click on display options and select “Show 60 results per page”. By doing this, you will be able to see 60 files at once in the library. Now you can click on the select all checkbox and click the download button. This will help you to download files at once.
If you have more than 60 files, then click on the next page and then again download all files. This process will become hectic if you have more than 1000 files in the library.
Approach 2:URL hack
I performed some searches on google and found out that there is another way to download all files as zip by specifying the contentversionIds of the file in the URL. I can call it a URL hack and everyone mentioned that it is not recommended way. Below is the URL format that you need to use:
Just paste this URL and files will be downloaded as zip files.
If you have more than 1000 files in the library, then you have to build a different URL by specifying 10 or 15 record IDs in one URL. I was able to download a zip file with a size of around 400Mb using one URL.
Approach 3: Using Apex Script & Tab Save Chrome Extension
One of my friends told me about the Tab Save chrome extension. You just need to paste all files download URL and click on download.
This will download all files in your downloads folder or folder that you have specified in chrome download settings.
Now we wrote a simple apex script that will send an email with all URL s(file download URL) in the CSV file. Suppose you want to get download URLs for all files present in the library “Demo Download Library”, then refer to the below script:
Run the above script in the developer console by specifying your library name. You will receive an email with all file download URLs. Now you just copy and paste these URLs in the Tab Save edit window and click on download.
I have used the Tab Save extension to download around 1500 files and it was working fine.
Now you have all 3 approaches and you can decide what to choose based on your requirements.
Hope this will help!!