You need to sign in to do that
Don't have an account?

Make ContentVersion downloadable/accessible via Sites
Hello Everyone,
I'm trying to make some files we uploaded into salesforce crm content downloadable or accessible by another page via Sites. For instance, say, an mp3, either downloaded or requested by mediaplayer on a webpage.
According to the docs 'To download a document via the API, you must export the VersionData of the document.'
Well... I've tried a couple variations with a visualforce page to retrieve/export the contentversion, but (as expected) no luck.
Does anyone have any good ideas on how to do this?
Thanks in advance,
e.
Here is a working example:
http://sitesdemo.force.com/abtest
The link on this page would look like this (the format is different than what I posted before, sorry)
All Answers
5 months and not a word? I am having a problem with this as well.
you need to create a custom controller and using content api retrieve the content id.
once you do this on your visual force page you can create a link like following
<apex:outputLink value="#" onclick="window.open('http://abc.force.com/sitepath/sfc/#version?selectedDocumentId={!contentDoc.doc.ContentDocumentId}')">{!contentDoc.doc.Title}</apex:outputLink>
where abc.force.com/path/is your site url
and assume that you return the content document id via the contentDoc.doc.ContentDocumentId from your controller
you might have doe this much so far. the missing piece in our case might be the content workspace access
you need to create a public group and add your site user to this public group.
and finally you need to add this public group to your content workspace so that your site will have read access to the content workspace
thank you. this thread gave me ideas.
But aren't Sites users 'guest' licenses (i.e. can't view Salesforce CRM Content )?
When I do this I get the following message:
Yes. I am facing same problem too. I too get the same error msg as above!
What about the 'Guest' licences?
Code snippet:
you need to use the version id in the code
you need to create a public group and add your site user to this public group.and finally you need to add this public group to your content workspace so that your site will have read access to the content workspace
Hi Bulent Cinarkaya
Thanks for the quick reply.
What i understood from your reply is that the user will have access to Content Document object from the steps i follow about creating public group and all.
but when on site, i will click on the link it will ask for ID and password and this will get restricted to salesforce users only.
My Site will be public and should be accesible to all users instead of only salesforce users.
hence i am using Content delivery. Salesforce generates the URL which is accessible to all users without ID/Password but i am not able to retrieve it dynamically. I have to hard code it in my VF page of site.
Can you provide a solution so that it is available for all users instead of only salesforce users or how can i dynamically fetch the URL of content delivery into my site.
the example I provided works for public sites, and not specific to authenticated users.
Hi Bulent
Thanks again for the quick turnaround.
I would like a deeper insight then.
I would elaborate what i am facing and why i believe it is restricted to salesforce user.
I did all the steps of creating the group and adding it as reader in my workspace. But the guest site user which i added does not have the access to Salesforce CRM content. So when i click on the following link
https://cs3.salesforce.com/sfc/#version?selectedDocumentId=069XXXXXXXXXXXX it comes up with that error about Insufficient Privileges.
If with this URL https://cs3.salesforce.com/sfc/servlet.shepherd/version/download/068XXXXXXXXXXXX?asPDF=true
then it asks for ID and password.
I believe i need to get that Salesforce CRM content checkbox checked then only i can access the workspace and I am not able to get that done in Guest license site user. So i think only salesforce users who have access to salesforce crm content can use it other site user cannot.
can you please explain in detail?
Here is a working example:
http://sitesdemo.force.com/abtest
The link on this page would look like this (the format is different than what I posted before, sorry)
Hi Bulent
Thanks for the quick reply again.
That was great solution.
I was doing silly mistake for the URL that was restriciting me.
Thanks a lot.
Hi Bulent,
there is no other url to access content.
Hi Bulent,
I have been trying to use this method and have so far been unsuccessful - we even though I'm accessing it via sites as an authenticated user I get taken to the login screen for the org. Presumably this is because the "Salesforce CRM Content User" checkbox is unmarked for the portal user I am using, however this box is disabled on the user's edit page - I am an Administrator on the org and CRM Content is enabled as we have a document in it.
The end game is that we're trying to serve up content in an iframe on a visualforce page on the site, preferably using the preview functionality accessible when you create a content delivery, but apart from not being able to get the URL for that even the method in this thread isn't working for these users.
Any ideas?
Thanks,
Matt
This method to access a content file via a public URL appears to be broken with the Spring 2011 release. Can anyone confirm this? It was working fine until the release, then it stopped working. Here's how we have it set up:
Jason,
Do you have any updates on this? I set up as indicated in the thread for couple of days now on Spring '11 and I've been getting same response. No Error and no document. Let me know if you hear about a fix.
Thanks,
Sathish
Sathish,
No answer yet, but we just opened a case with Salesforce support (case number 04300024). I'll post here if I hear of a solution. I'm hoping the URL just changed and they haven't notified anyone yet.
Thank you so much. Hope you get a response soon.
With this solution, were you able to open a Content document to public user wihtout logging into Salesforce prior to Spring '11 upgrade?
Here's the latest feedback from Salesforce support (not very reassuring):
Your case has been escalated to Tier 3 and the original determination is that this is considered to be a type of url hacking and was never officially supported.
As this is functioning as expected, I will be reducing the severity level to 3 as Tier 3 continues investigating any possible workarounds for this.
In general, providing content to sites public users from Content or Documents was never officially supported. The only officially supported mechanism is via Static resources.
I will keep you updated on Tier 3’s progress on a possible workaround.
Any update from tier 3 on this?
Good news! According to Tier 3 support, the issue has been resolved for the Spring 2011 release. I just confirmed that the content URLs appear to be working correctly on one of our Spring 2011 production orgs.
I tried this approach. This allows me to download the content.. I would like to use the Preview functioanlity that is available in SFDC.. Is that possible to expose the content with the Preview Mode?
What approach? Can someone please give a clear and concise definitive answer and solution?
Thanks
Clyde,
Read the full thread of this discussion from the beginning and you'll find sample code and step-by-step instructions. For example, my earlier instructions now work correctly -- see Message 16 on this page:
http://boards.developerforce.com/t5/Force-com-Sites/Make-ContentVersion-downloadable-accessible-via-Sites/m-p/239725#M4262
We've been told by Salesforce support that this undocumented feature will continue to be supported in future releases.
Regards.
I am facing the same issue now. Need to access/download the Salesforce CRM Content Document from within Sites (using Partner portal authentication). Can you please let me know how we can do that? Can this be done now?
We are trying to access the document using this url :-
is this correct? but its not working :( please help..
Regards
Sathya
Crazy... I found the issue :D
it was my mistake..
There are two objects, one is contentversion and another is contentdocument.
I was giving the id of contentdocument (in place of <contentversionid>) in the below url.. when i changed it to contentversion id it downloaded the document from the sites (authenticated through partner portal)
http://<siteurl>/<siteprefix>/sfc/servlet.shepherd/version/download/<ContentVersionId>?asPdf=false&
Thanks everyone.
Hi All,
Is there any option to download or view the video file (uploaded in salesforce crm) via chatter api.
Please guide me around...Oauth authentication has been done but iam unable to find any clear step whether download a video file(say mp4 file) can be done via api.
Thanks.
did Found a Way to enable it to Guest Licenses. but it will require for you Salesforce CRM Content setting to have Public Links.
Basically is using this : https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_contentdistribution.htm
object,
What I did is Create a Content Distribution for the Content Version and then after Creating it, you must get the ContentDownloadURL in the Image Source of the Site that you want and there you go.
Please look at this simple Example: Hope this helps