Skip to content

Instantly share code, notes, and snippets.

@hrchu
Created May 10, 2016 02:44
Show Gist options
  • Save hrchu/1cb4f9c8c7e3751e76be5917750e7a5b to your computer and use it in GitHub Desktop.
Save hrchu/1cb4f9c8c7e3751e76be5917750e7a5b to your computer and use it in GitHub Desktop.
aws java sdk force v2 signing for s3 compatible storage
public static void main(String[] args) {
ClientConfiguration clientConf = new ClientConfiguration();
clientConf.withSignerOverride("S3SignerType");
AWSCredentials myCredentials = new BasicAWSCredentials("XX", "DD");
client = new AmazonS3Client(myCredentials, clientConf);
client.setEndpoint("http://s3.com");
ObjectMetadata metadata = new ObjectMetadata();
metadata.setContentType("application/octet-stream");
InputStream data = new ByteArrayInputStream("qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq".getBytes(StandardCharsets.UTF_8));
client.putObject("test", "qq", data, metadata);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment