First of all i have a question how will i pull my files that i find in chatter Tab for community user through Chatter Connect In APEX or REST API?

And Also I need to display Icon based on image .Lets say if its word doc then a word doc image Icon should appear and similarly image of pdf ,if its pdf file .

2 Answers 2


If you need to pull only your files then you will need to query the ContentVersion Standard Object.

ContentVersion documentation

ContentVersion is the standard object where each revision of a document is stored in Salesforce Content. Chatter files are also stored as ContentVersions.

It has a field called FileType that returns the type of content determined by ContentUrl for links or PathOnClient for documents. That will help you to determine what icon to display depending on the file type.

You can do a query like the following:

List< contentVersion = [SELECT Id, FileType, Title, ContentUrl, PathOnClient, VersionData from contentVersion WHERE OwnerId =: UserInfo.getUserId()];

VersionData is the field that has the encoded file data.

I would like to mention that Chatter REST API provides the following resource that allows you to get information about a list of files:


Hope it helps!


For the Chatter REST API, the endpoint that I think you're looking for is User Files, General. And since you'd like to use it in a community, the REST request would look like this, where XX is 24 or higher:

GET /services/data/vXX.0/connect/communities/<communityId>/chatter/users/<userId>/files

There are some other file endpoints that you can read about in the "Files Resources", "Groups Resources", "Topics Resources", and "Users Resources" sections of the Chatter REST API documentation.

Similar methods aren't available in Connect in Apex yet, so the Apex solution would be to query ContentVersion as mentioned in the other answer.

To display the icon, you can identify the type with the fileType property returned in the request. But I think you'd have to implement your own logic to display the proper icon.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .