Skip to main content

I have a custom object(filechild), under which we have "Files" attached.  In an apex component, I am displaying the file name with a download button. I am able to fetch the file names and display on the community but when I click on download button I get the error :

Unable to download a file in community

The file sharing type = "I" and Visibility = "All Users".  Url on download button : Community Base Url + 'sfc/servlet.shepherd/document/download/' + ContentdocumentId  + '?operationContext=S1'  .  Since I am able to fetch the file name, it looks I am either missing an access for download or my download button has wrong url. What is prohibiting me to download any file?    @Salesforce Certified Professionals

 

#Experience Cloud

답변 12개
  1. 2021년 10월 1일 오전 2:45

    @Prabhjit Singh

     

    To confirm, do you believe the user has access to the file?  You mention you can see the name, but is seeing the name actually querying as the logged in user, or might it be a system user?

     

    Do you have a way to verify the logged in user has access to the custom object the file is shared with? 

     

    Can you temporarily expose the custom object within your community via a record page, and have the logged in user go to the custom object in the UI and then go to the Files related list and see what happens if you try to download?

     

    One edge case is if the ContentDocument SharingPrivacy is set to "private on record":

    ContentDocument | SOAP API Developer Guide | Salesforce Developers

     

    I think it's unlikely unless the issue only happens with a certain document.  If this setting was set, the file wouldn't be visible in the related list to the logged in user, so I think checking the OOTB UI functionality could help narrow down the issue.