You need to sign in to do that
Don't have an account?
Surya Chandra Rao Gandreddi
I'm trying to upload files (image/audio/video) to FeedItem in chunks, the above example shows how I'm doing the same while writing to a document. But If try to do the same with FeedItem it says "FeedItem.ContentData is not writeable" so I've tried the following code:
But this creates ContentVersions of incomplete chunks. Any pointers on how can I achieve this more neat.
Thank you.
Upload File (image/audio/video) to FeedItem in chunks
public static String upload(String folderId, String documentId, String fileName, String base64BlobValue) { if(documentId == '' || documentId == null) { Document document = new Document(Name=fileName, FolderId=folderId, Body=EncodingUtil.Base64Decode(base64BlobValue), IsPublic=true); insert document; return document.Id; } else { Document document = [select Id, Body from Document where Id = :documentId]; update new Document(Id = documentId, Body = EncodingUtil.Base64Decode(EncodingUtil.Base64Encode(document.Body) + base64BlobValue)); return documentId; } }Hi,
I'm trying to upload files (image/audio/video) to FeedItem in chunks, the above example shows how I'm doing the same while writing to a document. But If try to do the same with FeedItem it says "FeedItem.ContentData is not writeable" so I've tried the following code:
FeedItem imageFeedItem = [select Id, ContentData, RelatedRecordId from FeedItem where Id = :imageFeedItemId]; ContentVersion content = new ContentVersion(); content.versionData = EncodingUtil.Base64Decode(EncodingUtil.Base64Encode(imageFeedItem.ContentData) + base64BlobValue); content.pathOnClient = fileName; content.ContentDocumentId = [Select ContentDocumentId from ContentVersion where id=:imageFeedItem.RelatedRecordId].ContentDocumentId; insert content;
But this creates ContentVersions of incomplete chunks. Any pointers on how can I achieve this more neat.
Thank you.