2

I have an experience cloud site with a lightning web component that contains a download link. Clicking the download link produces the following error:

top.location='https://{domain}.cs196.force.com/ex/errorduringprocessing.jsp'

I'm using the following code:

lwc.html

<lightning-button-icon 
   icon-name="utility:download"     
   title="Download"
   onclick={downloadFile}
   data-id={doc.ContentDocumentId}>
</lightning-button-icon>

lwc.js

downloadFile(event){
  const fileId = event.target.dataset.id;
  const getUrl = window.location;
  const baseUrl = getUrl.protocol + "//" + getUrl.host + "/";
  let url = baseUrl +"sfc/servlet.shepherd/document/download/" + fileId;
  window.open(url, "_blank");
}

I have attempted to change ContentDocumentId with LatestPublishedVersionId as suggested by one post, but this yields an entirely different error. A pop-up says:

This content pack is empty, or contains only links and Google Docs, and cannot be downloaded.

The interesting thing is that this occurs on only on sandbox2. In sandbox1, the download occurs as expected. The user attempting to download the file is the owner. I suspect a sandbox setting or permission but I cannot seem to locate it. Any help would be appreciated.

3
  • do you try on both Sandboxes to download from Experiences?
    – ytiq
    Commented Aug 9, 2021 at 13:52
  • In Sandbox1, I can download the file from experience In Sandbox2, I receive the error: > top.location='https://{domain}.cs196.force.com/ex/errorduringprocessing.jsp' Both sandboxes have the same lwc code.
    – Dave
    Commented Aug 9, 2021 at 13:58
  • can it be that the Id is hardcoded? or the id does not exist? I mean filed. You can try to get a ContentDocumentId directly from the org and harcode this URL with your file id in a new browser tab. For me it works if the Id of the contentdocument exists... else I get the same error as you. Commented Sep 16, 2021 at 14:11

2 Answers 2

0

I have faced the issue. ContentDocument is successfully downloaded in sandbox, but the error appears in production.

In my case, the link was used by guest users in a public site. The error appeared due to a wrong sharing rule in production: accounts became hidden from the guest users, while they need to have access to the records, associated with the document(accounts in my case) in order to download it. After we'd fixed the rule, the error has dissapeared.

0

I also faced this issue earlier I thought it was file sharing issue to community users but when I check file access it was already there after some research I find a solution. Maybe it will be helpful for you as well.

earlier I was trying to download the file through this URL:

https://mydomain.com/sfc/servlet.shepherd/document/download/{ContentDocumentId}

Here you just need to add the community site name as well. Like this :

https://mydomain.com/{portalName}/sfc/servlet.shepherd/document/download/{ContentDocumentId}

Here portalName will be your site name(It will be unique). This is working fine for me to download files through the community/experience site.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .