No Results
Search Tips:
- Please consider misspellings
- Try different search keywords
Newer Version Available
Post a Feed Element with a New File (Binary) Attachment
This example calls the postFeedElement(String, ConnectApi.FeedElementInput,
ConnectApi.BinaryInput) method to post a feed item with a new file
(binary) attachment.
1swfobject.registerObject("clippy.codeblock-0", "9");ConnectApi.FeedItemInput input = new ConnectApi.FeedItemInput();
2input.subjectId = 'me';
3
4ConnectApi.ContentCapabilityInput contentInput = new ConnectApi.ContentCapabilityInput();
5contentInput.title = 'Title';
6
7ConnectApi.FeedElementCapabilitiesInput capabilities = new ConnectApi.FeedElementCapabilitiesInput();
8capabilities.content = contentInput;
9
10input.capabilities = capabilities;
11
12String text = 'These are the contents of the new file.';
13Blob myBlob = Blob.valueOf(text);
14ConnectApi.BinaryInput binInput = new ConnectApi.BinaryInput(myBlob, 'text/plain', 'fileName');
15
16ConnectApi.ChatterFeeds.postFeedElement(Network.getNetworkId(), input, binInput);