I'm working on an app to migrate chatter answer question records into another object.
Using apex code I have a process that can map question fields, but haven't found a way of mapping/migrating inline images.
Question's body is a Rich Text Area field and inline image are stored as contentReference leaving an img tag on the body of the question. The img URL has a reference to the question Id and also to a contentReference Id. Has anyone been able to access the image file other than via the URL itself?
Ideally I'd use another API to migrate images apart from the apex logic I have, but haven't found a way.


I've found this wonderful article:

You can access base64 body of your image by initizalising PageReference with your URL, and then taking content of it. After that you can store this e.g. in your documents.

String container = 'https://c.na30.content.force.com/servlet/rtaImage?'+
PageReference pageRef = new PageReference(container);

string strFolderId = '00l36000000aPPB';

Document doc = new Document();
doc.Name = 'pic1';
doc.Type = 'png';
doc.Body = pageRef.getContent();
doc.FolderId = strFolderId;
doc.Description = 'chatterPostId';

insert doc;

You can create trigger, which can transfer rtaImage to document image and replace it with document url src. You can send callout with image body...

  • Ilya, I ended up implementing a workaround based on you suggestion, moved the content migration to a separate batch process and used allowCallouts. I can convert up to 100 images per run, but we can live with that. Sorry the late update, and thanks – andrea Aug 30 '16 at 15:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.