Note: To download the file, require the Content Version record Ids
For Single File
Use the below URL to download the single file from the salesforce.URL: https://<YOUR_SFDC_BASE_URL>/sfc/servlet.shepherd/version/download/068XXXXXXXXXXXX
String idCntDoc = '068XXXXXXXXXXXX';
String strURL = URL.getSalesforceBaseUrl().toExternalForm() + '/sfc/servlet.shepherd/version/download/' + idCntDoc;
System.debug('URL ===> '+strURL);
For Multiple Files
URL: https://<YOUR_SFDC_BASE_URL>/sfc/servlet.shepherd/version/download/068XXXXXXXXXXXX/068XXXXXXXXXXXX
above URL downloads the files in ZIP folder
list<String> lstCntVersionIds = new list<String>{'068XXXXXXXXXXXX', '068XXXXXXXXXXXX'};
String strURL = URL.getSalesforceBaseUrl().toExternalForm() + '/sfc/servlet.shepherd/version/download/';
for(String iterator : lstCntVersionIds) {
strURL += iterator + '/';
}
strURL = strURL.removeEnd('/');
System.debug('URL ===> '+strURL);
Shaik, I need help with this as I'm getting an error during processing.
ReplyDeleteFor the SFDC base URL, would that the domain?
Also, I'm just adding the URL into a browser (Chrome) window.
Thanks.
thank you this was driving me crazy and this is the only example that worked!
ReplyDeleteCan we select the name of downloaded file dynamically ?
ReplyDeleteThank you!!!!! This works great. So much better than any other solution I can find to bulk download contentversion files from SalesForce.
ReplyDelete