davidmoten / aws-lightweight-client-java

A lightweight java client for the AWS API. Signs requests with AWS Version 4 and offers helpful builders.
Apache License 2.0
29 stars 1 forks source link

is it possible to use this with other S3 compatible API endpoints? #50

Closed PicoCreator closed 2 years ago

PicoCreator commented 2 years ago

From the configuration example and code, it seems like the the URL end point cannot be configured directly.

That it must be using the AWS s3 endpoints.

davidmoten commented 2 years ago

Hi, there is a way to customize the endpoint by customizing the HttpClient:

HttpClient hc = new HttpClient() {

    final HttpClient c = HttpClient.defaultClient();

    @Override
    public ResponseInputStream request(URL endpointUrl, String httpMethod, Map<String, String> headers,
            byte[] requestBody, int connectTimeoutMs, int readTimeoutMs) throws IOException {
        // modify endpoint URL here as you wish
        URL u = endpointUrl;
        return c.request(u, httpMethod, headers, requestBody, connectTimeoutMs, readTimeoutMs);
    }
};
Client s3 = Client //
        .s3() //
        .regionNone() //
        .accessKey("accessKey") //
        .secretKey("secretKey") //
        .httpClient(hc) //
        .build();

What are you connecting to? An Outposts environment or something else? If I know a bit more I can make something easier in the library.

davidmoten commented 2 years ago

I think the ability to specify a hostname supplier function to the Client builder would do the job. Is that enough for you?

davidmoten commented 2 years ago

Explicit support for a custom endpoint url is in 0.1.13 on Maven Central now