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
dke01dke01 

Amzon S3 getObject

I have been using Force for AWS (http://wiki.developerforce.com/index.php/Installing_Force_for_Amazon_Web_Services)

 

But it seems most of the methods are not fully finished. Has any one completed the sections in S3.cls that are commented out. Inparticular getObject?

If you have it would be greatly appreciated if you could post your soultion.

Message Edited by dke01 on 12-07-2009 10:20 PM
Best Answer chosen by Admin (Salesforce Developers) 
dke01dke01

Guess no one else is using AWS, so I updates the APEX for S3 class myself It was very easy in the end. Here is what I did.


In GetObject comment out the  request_x.Credential line

public S3.GetObjectResult GetObject(String Bucket,String Key,Boolean GetMetadata,Boolean GetData ,Boolean InlineData ,String AWSAccessKeyId, DateTime Timestamp, String Signature) { S3.GetObject_element request_x = new S3.GetObject_element(); S3.GetObjectResponse_element response_x; request_x.Bucket = Bucket; request_x.Key = Key; request_x.GetMetadata = GetMetadata; request_x.GetData = GetData; request_x.InlineData = InlineData; request_x.AWSAccessKeyId = AWSAccessKeyId; request_x.Timestamp = Timestamp; request_x.Signature = Signature; // request_x.Credential = Credential;

Map<String, S3.GetObjectResponse_element> response_map_x = new Map<String, S3.GetObjectResponse_element>(); response_map_x.put('response_x', response_x); System.debug(request_x); WebServiceCallout.invoke( this, request_x, response_map_x, new String[]{endpoint_x, '', 'http://s3.amazonaws.com/doc/2006-03-01/', 'GetObject', 'http://s3.amazonaws.com/doc/2006-03-01/', 'GetObjectResponse', 'S3.GetObjectResponse_element'} ); response_x = response_map_x.get('response_x'); return response_x.GetObjectResponse; }

 

Chage GetObjectResult orginal code to also get status and  field_order

public class GetObjectResult { public S3.MetadataEntry[] Metadata; public String Data; public DateTime LastModified; public String ETag; public Status Status; private String[] Status_type_info = new String[]{'Status','http://s3.amazonaws.com/doc/2006-03-01/','Status','1','1','false'}; private String[] Metadata_type_info = new String[]{'Metadata','http://s3.amazonaws.com/doc/2006-03-01/','MetadataEntry','0','-1','false'}; private String[] Data_type_info = new String[]{'Data','http://www.w3.org/2001/XMLSchema','base64Binary','1','1','true'}; private String[] LastModified_type_info = new String[]{'LastModified','http://www.w3.org/2001/XMLSchema','dateTime','1','1','false'}; private String[] ETag_type_info = new String[]{'ETag','http://www.w3.org/2001/XMLSchema','string','1','1','false'}; private String[] apex_schema_type_info = new String[]{'http://s3.amazonaws.com/doc/2006-03-01/','true'}; private String[] field_order_type_info = new String[]{'Status','Metadata','Data','LastModified','ETag'}; }

 

 

 

 Uncomment GetObjectResponse_element class

public class GetObjectResponse_element { public S3.GetObjectResult GetObjectResponse; private String[] GetObjectResponse_type_info = new String[]{'GetObjectResponse','http://s3.amazonaws.com/doc/2006-03-01/','GetObjectResult','1','1','false'}; private String[] apex_schema_type_info = new String[]{'http://s3.amazonaws.com/doc/2006-03-01/','true'}; private String[] field_order_type_info = new String[]{'GetObjectResponse'}; }

 

Un comment the Status class

public class Status { public Integer Code {get;set;} public String Description {get;set;} private String[] Code_type_info = new String[]{'Code','http://www.w3.org/2001/XMLSchema','int','1','1','false'}; private String[] Description_type_info = new String[]{'Description','http://www.w3.org/2001/XMLSchema','string','1','1','false'}; private String[] apex_schema_type_info = new String[]{'http://s3.amazonaws.com/doc/2006-03-01/','true'}; private String[] field_order_type_info = new String[]{'Code','Description'}; }

 

 

 

All Answers

dke01dke01

Guess no one else is using AWS, so I updates the APEX for S3 class myself It was very easy in the end. Here is what I did.


In GetObject comment out the  request_x.Credential line

public S3.GetObjectResult GetObject(String Bucket,String Key,Boolean GetMetadata,Boolean GetData ,Boolean InlineData ,String AWSAccessKeyId, DateTime Timestamp, String Signature) { S3.GetObject_element request_x = new S3.GetObject_element(); S3.GetObjectResponse_element response_x; request_x.Bucket = Bucket; request_x.Key = Key; request_x.GetMetadata = GetMetadata; request_x.GetData = GetData; request_x.InlineData = InlineData; request_x.AWSAccessKeyId = AWSAccessKeyId; request_x.Timestamp = Timestamp; request_x.Signature = Signature; // request_x.Credential = Credential;

Map<String, S3.GetObjectResponse_element> response_map_x = new Map<String, S3.GetObjectResponse_element>(); response_map_x.put('response_x', response_x); System.debug(request_x); WebServiceCallout.invoke( this, request_x, response_map_x, new String[]{endpoint_x, '', 'http://s3.amazonaws.com/doc/2006-03-01/', 'GetObject', 'http://s3.amazonaws.com/doc/2006-03-01/', 'GetObjectResponse', 'S3.GetObjectResponse_element'} ); response_x = response_map_x.get('response_x'); return response_x.GetObjectResponse; }

 

Chage GetObjectResult orginal code to also get status and  field_order

public class GetObjectResult { public S3.MetadataEntry[] Metadata; public String Data; public DateTime LastModified; public String ETag; public Status Status; private String[] Status_type_info = new String[]{'Status','http://s3.amazonaws.com/doc/2006-03-01/','Status','1','1','false'}; private String[] Metadata_type_info = new String[]{'Metadata','http://s3.amazonaws.com/doc/2006-03-01/','MetadataEntry','0','-1','false'}; private String[] Data_type_info = new String[]{'Data','http://www.w3.org/2001/XMLSchema','base64Binary','1','1','true'}; private String[] LastModified_type_info = new String[]{'LastModified','http://www.w3.org/2001/XMLSchema','dateTime','1','1','false'}; private String[] ETag_type_info = new String[]{'ETag','http://www.w3.org/2001/XMLSchema','string','1','1','false'}; private String[] apex_schema_type_info = new String[]{'http://s3.amazonaws.com/doc/2006-03-01/','true'}; private String[] field_order_type_info = new String[]{'Status','Metadata','Data','LastModified','ETag'}; }

 

 

 

 Uncomment GetObjectResponse_element class

public class GetObjectResponse_element { public S3.GetObjectResult GetObjectResponse; private String[] GetObjectResponse_type_info = new String[]{'GetObjectResponse','http://s3.amazonaws.com/doc/2006-03-01/','GetObjectResult','1','1','false'}; private String[] apex_schema_type_info = new String[]{'http://s3.amazonaws.com/doc/2006-03-01/','true'}; private String[] field_order_type_info = new String[]{'GetObjectResponse'}; }

 

Un comment the Status class

public class Status { public Integer Code {get;set;} public String Description {get;set;} private String[] Code_type_info = new String[]{'Code','http://www.w3.org/2001/XMLSchema','int','1','1','false'}; private String[] Description_type_info = new String[]{'Description','http://www.w3.org/2001/XMLSchema','string','1','1','false'}; private String[] apex_schema_type_info = new String[]{'http://s3.amazonaws.com/doc/2006-03-01/','true'}; private String[] field_order_type_info = new String[]{'Code','Description'}; }

 

 

 

This was selected as the best answer
jg@hhsjg@hhs

I'm using this toolkit now, as well.  Are you using the GetObject method for retrieving a file out of an S3 bucket?  This is what I'd like to do, but I'm not sure if this is the correct way of going about it.

Vincenzo BenfanteVincenzo Benfante

Hi dke01 and jg@hhs,

i'm new with this toolkit and i would know if with it is possible download and save on pc the file stored on S3.

 

Now i'am able to upload file from my web app write in Apex and Visualforce but i don't know if is possible download the file that i have saved on S3.

Ashish  VermaAshish Verma
Hi @dke01 and @jg@hhs, have you guys abeen able to retrieve the files from a bucket in amazon s3 using getObject??