Find your content:

Search form

You are here

Get the body of Chatter files?


Using Apex, how can I get the body of files uploaded using Chatter? I want to send the document with web service methods.

Attribution to: NHL

Possible Suggestion/Solution #1

ContentData is no longer a query-able field in API version 33 +

Attribution to: Mark Hartnady

Possible Suggestion/Solution #2

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.

Attribution to: Steven Herod

Possible Suggestion/Solution #3

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 :

Attribution to: techtrekker
This content is remixed from stackoverflow or stackexchange. Please visit

My Block Status

My Block Content