LogWriter log = LogWriter.getInstance();
AWSCredentials awsCredentials = new AWSCredentials(_AKey,_PKey);
S3Service s3Service = new RestS3Service(awsCredentials);
S3Bucket[] myBuckets = s3Service.listAllBuckets();
if(myBuckets != null){
log.logDetailed(toString(),"Connected to S3 !");
log.logDetailed(toString(), "_____________________________________");
}
log.logDetailed(toString(),"==>You have " + myBuckets.length + " Buckets in your S3" );
log.logDetailed(toString(),"==>You will send the file [" + _FileNm + "] to the bucket [" + _S3Buck + "]" );
String TargetBucket = _S3Buck;
File fileData = new File(_FileNm);
S3Object fileObject = new S3Object(fileData);
log.logDetailed(toString(),"==>Hash value: " + fileObject.getMd5HashAsHex());
log.logDetailed(toString(),"==>S3Object before upload: " + fileObject);
log.logDetailed(toString(),"_____________________________________");
// Upload the data objects.
s3Service.putObject(TargetBucket, fileObject);
log.logDetailed(toString(),"Sending file to S3 ...");
log.logDetailed(toString(),"_____________________________________");
log.logDetailed(toString(),"==>S3Object after upload: " + fileObject);
log.logDetailed(toString()," ");