You need to sign in to do that
Don't have an account?

Amazon Salesforce Integration
Hello,
I need to create folder under bucket on amazon s3 through REST webservice in salesforce .I am getting 503 as status code .Below is my REST class.Please do help
global with sharing class SalesForceAmazonWebservices{
public void s3RestPut() {
String Date1 = Datetime.now().formatGMT('EEE, dd MMM yyyy HH:mm:ss z');
String filename = 'test3';
String bucketname = 'Bucket1';
String Method = 'PUT';
HttpRequest req = new HttpRequest();
req.setMethod(method);
req.setEndpoint('http://aws-us-west-2.amazon.com/s3/'+ bucketname + '/' + filename);
req.setHeader('HOST','aws-us-west-2.amazon.com/s3/');
req.setHeader('content-type', filename);
req.setHeader('content-Encoding', 'base64');
req.setHeader('Date',Date1);
String stringToSign = 'PUT\n\n\n'+Date1+'\n/'+bucketname+'/'+filename + '/' ;
Blob mac = Crypto.generateMac('HMacSHA1', blob.valueof(stringtosign),blob.valueof('*******************'));
String signature = EncodingUtil.base64Encode(mac);
String authHeader = 'AWS' + '**************' + ':' + signature ;
req.setHeader('Authorization',authHeader);
req.setBody(filename);
Http http = new Http()
HTTPResponse res = http.send(req);
}
}
I need to create folder under bucket on amazon s3 through REST webservice in salesforce .I am getting 503 as status code .Below is my REST class.Please do help
global with sharing class SalesForceAmazonWebservices{
public void s3RestPut() {
String Date1 = Datetime.now().formatGMT('EEE, dd MMM yyyy HH:mm:ss z');
String filename = 'test3';
String bucketname = 'Bucket1';
String Method = 'PUT';
HttpRequest req = new HttpRequest();
req.setMethod(method);
req.setEndpoint('http://aws-us-west-2.amazon.com/s3/'+ bucketname + '/' + filename);
req.setHeader('HOST','aws-us-west-2.amazon.com/s3/');
req.setHeader('content-type', filename);
req.setHeader('content-Encoding', 'base64');
req.setHeader('Date',Date1);
String stringToSign = 'PUT\n\n\n'+Date1+'\n/'+bucketname+'/'+filename + '/' ;
Blob mac = Crypto.generateMac('HMacSHA1', blob.valueof(stringtosign),blob.valueof('*******************'));
String signature = EncodingUtil.base64Encode(mac);
String authHeader = 'AWS' + '**************' + ':' + signature ;
req.setHeader('Authorization',authHeader);
req.setBody(filename);
Http http = new Http()
HTTPResponse res = http.send(req);
}
}
Here is some updated sample code that I'm currently using
You'll get the 403(Forbidden) status code when there is something wrong with your signature. For me it was the dateTime and I using my local time zone.
Hope this helps
All Answers
debugging it is saying
"SignatureDoesNotMatch</Code><Message>The request signature we calculated does not match the signature you provided. Check your key and signing method."
Please do help me to resolve this error
Here is some updated sample code that I'm currently using
You'll get the 403(Forbidden) status code when there is something wrong with your signature. For me it was the dateTime and I using my local time zone.
Hope this helps