[SalesForce] unable to view contentversion file as public site user

I'm utilizing the following URL to load an image stored as a ContentVersion file in an IMG tag. It loads correctly in SF but not on the force.com public site:

/sfc/servlet.shepherd/version/renditionDownload?rendition=THUMB720BY480&versionId=06815000002QhYPAA0

I've tried loading the full URL path in the browser as well https://SITENAME.secure.force.com/sfc/servlet.shepherd/version/renditionDownload?rendition=THUMB720BY480&versionId=06815000002QhYPAA0

Any suggestions?

UPDATE:
I created the following sample VF page to exclude any other possibilities, the image loads correctly in SF, but when I try at the site URL it fails https://SITENAME.secure.force.com/apex/testcontent. Seems like its accessible but not rendering for some reason.

VF PAGE

<<apex:page controller="ctl_testContent" >
  <!-- attempt 1 -->
  <img src="/sfc/servlet.shepherd/version/renditionDownload?rendition=THUMB720BY480&versionId=06815000002QhYPAA0"/>

 <!-- test accessible -->
 {!cv.id}<br/>
 {!cv.versionData}
 </apex:page>

CONTROLLER:

public class Ctl_Testcontent {

public ContentVersion cv {get;set;}

public ctl_testContent() {
    cv = [SELECT Id,VersionData FROM ContentVersion WHERE id='06815000002QhYPAA0'];
}
}

OUTPUT:

[broken image]
06815000002QhYPAA0
core.filemanager.FileBlobValue@4bec7a37

UPDATE 2:
As an update to this I noticed documents are very easy to make public via /servlet/servlet.ImageServer?id={DOCUMENT_ID}&oid={ORG_ID}. It'd be nice if there was something similar for SF Files. At this point I may have to clone SF Files to be Documents simply for this functionality. I have gotten SF Files to render in public sites but its a headache of creating a group, adding the public sites user, creating a library, adding a file to the library etc…not going to work for my use case where its automated.

Best Answer

I faced this now too and after ....

  1. adding the guest user to a public group
  2. creating a public library and then adding the file to that library

If I use

<img style="max-width: 100%;" src="/sfc/servlet.shepherd/version/renditionDownload?rendition=THUMB720BY480&versionId={!ContentVersionId}"/> 

it doesn't work but if I use

<img style="max-width: 100%;" src="https://XXXX--YYYY--c.INSTANCE.content.force.com/sfc/servlet.shepherd/version/renditionDownload?rendition=THUMB720BY480&versionId={!ContentVersionId}"/>

then it works.

Compare your /apex version of the visualforce (right click on the image and open link) with the site.com URL and you will see there's a small difference.

Related Topic