I am trying to use aws-sdk-java AwsS3client to talk to a minio storage. From the CLI I am able to do:
aws --profile=minioplay --endpoint-url https://play.minio.io:9000 s3 cp logback.xml s3://miniohstest-jixusroqeb --debug
thus using a non default profile and a custom endpoint.
Not sure how to do this (would I be able to ?) from the java sdk.
I roughly translated the above awscli
command to this scala snippet :
val cred = ...
val endpoint = "https://play.minio.io:9000"
val client = AmazonS3ClientBuilder
.standard()
.withCredentials(cred)
.withEndpointConfiguration(
new EndpointConfiguration(
endpoint,
AwsHostNameUtils.parseRegion(endpoint, AmazonS3Client.S3_SERVICE_NAME)
)
)
.build()
Using the above client I am only able to make very simple requests such as :
client.listBuckets().asScala.foreach(println(_))
which works. But when I try to do something advanced such as :
val listRequest = new ListObjectsRequest()
.withBucketName("miniohstest-jixusroqeb")
//.withPrefix(r.getURI.getPath)
//.withDelimiter(delimiter)
val res = client.listObjects(listRequest)
res.getObjectSummaries.forEach(x => println(x.getKey))
it throws the following exception :
Exception in thread "main" com.amazonaws.SdkClientException: Unable to execute HTTP request: miniohstest-jixusroqeb.play.minio.io
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.handleRetryableException(AmazonHttpClient.java:1114)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeHelper(AmazonHttpClient.java:1064)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.doExecute(AmazonHttpClient.java:743)
What am I doing wrong?
I resolved this by setting withPathStyleAccessEnabled(true)
.