3

Iam using Amazon toolkit to integrate SF with Amazon S3.

I want to render the content(image) of files in a bucket when bucket is selected from a selectlist. Like ListBucket, I am calling a method getObject'which in turn calls the webservice operation GetObject from the S3 class. I can see the request and response(200) in my developer console but there is an exception:

ERROR: Web service callout failed: Unable to parse callout response. Apex type not found for element Status.enter image description here

Can someone help me to resolve this please.?

[EDIT]

This is The method which is in controller which further makes a call to a method of S3 class which performs a web service callout.

-

- public PageReference GetObject() { try{ Datetime now = Datetime.now(); String Delimiter = null;
Boolean GetMetadata =true; Boolean GetData=true; Boolean InlineData=true; System.debug('GetObject for bucket: ' + bucketToList);

//This performs the Web Service call to Amazon S3 and retrieves all the objects in the specified bucket

        S3.GetObjectResult response = as3.GetObject(bucketToList,'demo4'   ,GetMetadata,GetData,InlineData,as3.key,now,as3.signature('GetObject',now),as3.secret);

        return null;
     }
        catch(Exception ex){
        System.debug('EXCEPTION: ' + ex);
        getobjectErrorMsg =    ex.getMessage();
        ApexPages.addMessages(ex);
        return null; 

    }
    }
}
  • I'm looking for a similar case . Anybody having solution to this can please guide . – JJoseph Dec 5 '14 at 5:15
  • I'm not familiar with the Amazon toolkit specifically, however I imagine it would be something to do with it trying to deserialize the XML response into an Apex class that is missing a property called "Status". If you are able to provide the line of code that is making the callout that would be helpful. – luke.mcfarlane Dec 8 '14 at 1:58
3
+50

Ok , so I have resolved the error above after following the link: https://developer.salesforce.com/forums/ForumsMain?id=906F00000008xNYIAY

where I needed to Change GetObjectResult orginal code to also get 'status' and 'field_order'.

Now I have the issue of rendering the image content on page . I have the response string(image content) .

<apex:image value="data:image;base64,{!imagecontent}" />

The cntroller has getObject() with following code snippet

   S3.GetObjectResult response = as3.GetObject(bucketToList,'demo41' ,GetMetadata,GetData,InlineData,as3.key,now,as3.signature('GetObject',now),as3.secret);
  String imagecontent = response.data;

Is it the right way to go?

  • 1
    I presume that response.data is indeed in base64 form? Provided that it is then yes this shouldn't be a problem, although you may need to specify the image type e.g. "data:image/png,base64,". You could inspect the src attribute of the rendered image tag in your page to confirm. – luke.mcfarlane Dec 8 '14 at 21:48
  • 1
    Specifying value="data:image;base64,{!imageContent}" seems like the right approach, as long as your content is indeed Base64-encoded: css-tricks.com/data-uris – Marty C. Dec 9 '14 at 2:06
  • Hi, Yes My content is in Base64-encoded format as I have checked by specifying <apex:image value="data:image;base64,9j/weds/wdddewdsdfaffd......" /> But still I cant see the image in VF page . I need to get the image from controller to VF page and not as hardcoded. – SF beginner Dec 9 '14 at 11:23
  • 1
    Hi friends, now it is working , I think I was placing the <apex image> tag at wrong place in VF page. Thank you so much for your help.. – SF beginner Dec 9 '14 at 13:19
0

Did you enter your root account credentials into the AWS Credentials record you're using with the Force.com for Amazon Web Services app? The package was created a long time ago, probably before Amazon.com introduced the IAM feature.

I just installed the package in my DE org. I confirmed that while I cannot use an IAM account with the S3 Samples tab, the tab works with my root credentials. You can see the tab working as expected in the screenshot below.

S3 Samples tab

  • Hi @Marty-c , Yes I have correctly added the credentials. Also the whole thing is working correctly as in your case. There are some commented out methods of S3 class which I am trying to implement 'getObject'. withthis I want to render the contents (file- image/jpeg) in my VF page and doing this created this error above. – SF beginner Dec 8 '14 at 7:33
  • I tried to use IAM user credentials with salesforce package and its giving error. But when I used root user credentials with salesforce package, its working fine. So I agree with Marty that IAM thing doesnt work with salesforce package. Does salesforce plan to uprgrade the package to support IAM creds too ? – Chirag Mehta Jun 15 '15 at 9:58

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.