I have created a link on a visualforcepage for Guest user.The link shows correctly with the correct id. When I try to download the link a new page is opened with the error: urlsite/ex/errorduringprocessing.jsp'
When I do the same logged in everything works fine. To give permissions I have created 2 triggers 1 to set ContentDocumentLink.visibility = 'AllUsers' and 1 to set ContentVersion.Origin = 'C'.
No errors in my debug logs for Guest user
My url looks fine:
urlsite/sfc/servlet.shepherd/document/download/id
My visualforcepage looks like:
<apex:page standardController="Account" extensions="AttachmentfilesExt" sidebar="false" showHeader="false">
<apex:repeat value="{!idsContentdocument}" var="file">
<a href="{!URLFOR('/sfc/servlet.shepherd/document/download/'+ file.ContentDocumentId)}" target="_blank"> Click here </a>
{!file.ContentDocument.title}
<br/>
</apex:repeat>
</apex:page>
My controller:
public without sharing class AttachmentfilesExt{
public List<ContentDocumentLink> idsContentdocument {get;set;}
public Id accId;
public AttachmentfilesExt(Apexpages.StandardController con){
idsContentdocument = new List<ContentDocumentLink>();
try{
string token = apexpages.currentpage().getparameters().get('token');
system.debug('token: '+ token);
accId = [SELECT id , Token__c FROM Account WHERE Token__c =:token LIMIT 1].id;
system.debug('accId: '+ accId);
}
catch(Exception e){
System.debug('An exception accId occurred: ' + e.getMessage());
}
try{
system.debug('accId 2: '+ accId);
idsContentdocument = [SELECT ContentDocument.title, ContentDocumentId,LinkedEntityId FROM ContentDocumentLink WHERE LinkedEntityId = :accId];//:con.getId()
}
catch(Exception e){
System.debug('An exception idsContentdocument occurred : ' + e.getMessage());
}
}
}