Get the body of Chatter files?

If you query the ContentData column from the FeedItem object you should return a base64 encoded version of the file.

Keep in mind the following

  1. I believe SOQL will return only 1 row because it contains a base64 column in the results.
  2. Chatter supports files up to 2GB in size, so... a. Watch your heap size, the base64 file may be bigger than the permitted heap for an ApexClass
    b. Theres a max size on an outbound webservice call, and a maximum time to send it.

Personally, it'd be better if you queried Salesforce from the outside over the REST/SOAP API and then posted the file to the web service.


You need to query FeedItem where the Type is 'ContentPost' and grab the ContentData

SELECT Id, Type, Body, Title, LinkUrl, ContentData, ContentSize, ContentFileName, ContentType From FeedItem where Type = 'ContentPost' order by createddate, ID DESC

Here's the reference doc : http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_feeditem.htm

Tags:

Apex

Chatter