I generate the assigned URLs, but this is problematic for period bucket names and SSL because of the * .s3.amazonaws certificate, as described here:
http://shlomoswidler.com/2009/08/amazon-s3-gotcha-using -virtual-host.html
Is there a way to generate urls with the following format ?:
http://s3.amazonaws.com/bucket.name/key
I did not see the options in the API. I suppose I can do this “manually” by rearranging the URL, but I would prefer to avoid hacking if it is not needed.
Based on Michael's answer, here is the code I'm using now:
public static URL bucketNameAfterS3Url(URL url) {
int index = url.getHost().indexOf("s3");
String host = url.getHost().substring(index);
String bucket = url.getHost().substring(0, index - 1);
URL toUse;
try {
toUse = new URL(url.getProtocol(), host, url.getPort(), '/' + bucket + url.getFile());
} catch (MalformedURLException e) {
}
return toUse;
}
source
share