You need to sign in to do that
Don't have an account?
Abhinav Gupta
Download document from Chatter ContentPost
Hello Everyone,
I am dealing with FeedPost (Type=ContentPost) with file attachments in a visualforce page. I need to render a download link for the document attached in the Feed Post. I can't use visualforce chatter tags.
Is their any other way similar to what we do for attachment, as shown in code snippet below.
<apex:outputLink value="{!URLFOR($Action.Attachment.Download, attachment.id)}"> Download Now! </apex:outputLink>
assuming your feed is in "myfeed" and your controller is returning the link are you able to do the following.
<apex:outputLink value="{!myfeed.FeedPost.LinkUrl}">Download Now!</apex:outputLink>
see the last example in the recipes.
http://wiki.developerforce.com/index.php/Chatter_Code_Recipes
You might also want to check out the new Objects and features for accessing Chatter files in Spring 11. Check out the release notes for more info:
http://wiki.developerforce.com/index.php/Documentation#Release_Notes
Well, there is another, slightly unorthodox way to do this until Salesforce exposes the Doc/Attachment ID via the API.
What you can do now is to scrape the Chatter page to get the DocId and then use that construct the Download link. Please keep in mind that this may break in the future or if/when Salesforce decides to change the download URL, though...
Anyway, here is how to do it:
1.) Pass your feedPostId to the link.
2.) We consume the page, which only displays one chatter post, and search for distinguishing markup in the page, specifially the "feeditemtext".
3.) Find the download URL and find a distinguishing end to the link ("?asPdf" in our case).
4.) Return the substring.
We're missing try/catch, but as a proof on concept/stopgap, this will work for now.