function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
MayTheForceBeWithYouMayTheForceBeWithYou 

AJAX Proxy to load Chatter Images

Hi there,

 

So I'm trying to use the Salesforce AJAX proxy to load chatter profile images to avoid tainting my canvas due to the cross-domain issue of these images being stored on c.na1.content.force.com as opposed to c.na1.visual.force.com. I've just about done it except that I'm not sure how to decipher the text response the proxy returns and convert it into an image.

 

Here's a stripped-down version of my code:

 

sforce.connection.remoteFunction({
          url : SERVER_URL,
          requestHeaders : {
              'Authorization' : 'Bearer ' + SESSION_ID
          },
          onSuccess : function(response) {
                //alert(response);
                img.src=response;
          }
});  

To get an idea of the kind of text response I'm receiving you can do a view-source on the anonymous chatter image located at "/profilephoto/005/T" (Chrome users may have to manually type 'view-source:' before the URL)

 

I'm wondering if I might need to go through some sort of blob & base64 encoding/decoding in order to accomplish this. Your advice is greatly appreciated; thanks.