+ Start a Discussion
Scott.MScott.M 

Chatter File Uploads

What's the best way to upload a file to a chatter post in a custom interface in a visualforce page. Yes I know there is a visualforce component that provides all the chatter functionality, but let's say you don't want to use the component. How would you upload a chatter file with javascript remoting? 

 

Thanks!

Scott

jody_blyjody_bly

Use Chatter in Apex, which is a set of classes in the ConnectApi namespace that expose much of the Chatter REST API functionality in Apex. 

 

Call ConnectApi.ChatterFeeds.postFeedItem(String, ConnectApi.FeedType, String, ConnectApi.FeedItemInput, ConnectApi.BinaryInput)

 

The docs have sample code for uploading an attachment to a comment (scroll to the end of the page). You can edit the code to upload an attachment to a post. 

 

http://www.salesforce.com/us/developer/docs/apexcode/Content/connectAPI_ChatterFeedsClass.htm

 

Hope that helps,

Jody