function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Vivek.GuptaVivek.Gupta 

How to show contentDocument on Site/Community

Hi Everyone

I have a problem & I'm unable to resolve, please help 

How to show contentDocument on Site/Community
The link  "/sfc/servlet.shepherd/version/download/{ID}" works fine from the Org domain, but its not working for the Community domain. The error I receive is that the https://prnt.sc/pbnml6. I've tried also "/lightning/r/ContentDocument/{ID}/view" but getting sale issue.

 

Himanshu DangwalHimanshu Dangwal
Hello Vivek, 

Files not visible :
1. CUSTOMER COMMUNITY: Content is not available with Customer Community licenses.
2. LIGHTNING EXTERNAL APPS STARTER: Content is not available with Lightning External App licenses.

Allowed users
PARTNER COMMUNITY:    File and content permission ( Create, Read, Edit, Delete )
CUSTOMER COMMUNITY PLUS:    File and content permission ( Create, Read, Edit, Delete )
LIGHTNING EXTERNAL APPS PLUS : File and content permission ( Create, Read, Edit, Delete )



Ref:
 1. https://help.salesforce.com/articleView?id=users_license_types_communities.htm&type=5
 2. https://help.salesforce.com/articleView?id=networks_visibility.htm&type=5

I suppose it would help you.
 
Forix ForenForix Foren
To create a ContentDocument, you need to create a new ContentVersion object without setting the ContentDocumentId. From the Web Services ...
see here https://techywhale.com/steam-wallet-code-generator/
Vivek.GuptaVivek.Gupta

Forix Foren,

 

Please check my question what I'm asking  

Ram Sabarish 12Ram Sabarish 12
The download link on Community generates in the below format
/sfc/servlet.shepherd/document/download/{id}?operationContext=S1

Also you need to remove the additional "/s/" or "/lightning/"  from the download url. Refer a sample code below, will work on Aura as well as LWC. 
 
        var baseUrl = window.location.href;
        var downloadUrl;
      
        var documentId = "0691X0000017NatQAE"; //Spcify your Content Document Id here

        if(baseUrl.indexOf("/s/") != -1) {
            //Community URL
            downloadUrl = baseUrl.split("/s/")[0];

        }else if (baseUrl.indexOf("/lightning/") != -1) {
            //Lightning URL
            downloadUrl = baseUrl.split("/lightning/")[0];
        }


        downloadUrl = [downloadUrl, "/sfc/servlet.shepherd/document/download/", documentId, "?operationContext=S1"].join("");

        window.open(downloadUrl);

 
Ashwani Lingwal 11Ashwani Lingwal 11
Use /sfsites/c/sfc/servlet.shepherd/version/download/{ID} for communities instead