if (bucketName != null) bucketName = bucketName.trim();
bucketNameUtils.validateBucketName(bucketName);
Request<Void> request = createRequest(bucketName, null, createBucketRequest);
signRequest(request, HttpMethodName.PUT, bucketName, null);
HttpRequest httpRequest = convertToHttpRequest(request, HttpMethodName.PUT);
/*
* We can only send the CreateBucketConfiguration if we're *not*
* creating a bucket in the US region.
*/
if (region != null && !region.toUpperCase().equals(Region.US_Standard.toString())) {
XmlWriter xml = new XmlWriter();
xml.start("CreateBucketConfiguration", "xmlns", Constants.XML_NAMESPACE);
xml.start("LocationConstraint").value(region).end();
xml.end();
httpRequest.setContent(new ByteArrayInputStream(xml.getBytes()));
}
client.execute(httpRequest, voidResponseHandler, errorResponseHandler);
return new Bucket(bucketName);