-
Notifications
You must be signed in to change notification settings - Fork 906
Support 1.11.x's S3.getUrl and getResourceUrl #860
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
It's probably better to use 1.11.x for this feature, but here's a really gross, fragile way to do it in 2.x. URI s3Endpoint = URI.create("https://" + S3Client.serviceMetadata().endpointFor(Region.US_WEST_2));
SdkClientConfiguration sdkClientConfiguration = SdkClientConfiguration.builder()
.option(SdkClientOption.ENDPOINT, s3Endpoint)
.build();
AwsS3ProtocolFactory protocolFactory = AwsS3ProtocolFactory.builder()
.clientConfiguration(sdkClientConfiguration)
.build();
GetObjectRequestMarshaller requestMarshaller = new GetObjectRequestMarshaller(protocolFactory);
GetObjectRequest getRequest = GetObjectRequest.builder().bucket("foo").key("bar").build();
SdkHttpFullRequest httpRequest = requestMarshaller.marshall(getRequest);
URI objectUri = httpRequest.getUri(); It uses internal APIs, so it's subject to break in future SDK versions, and it only uses path-style addressing. It might even be easier to just build the URL manually than use this code... |
Well, that's a pretty ingenious workaround! |
I am new to S3 and not sure if the way I handle this is consistent. public class AmazonS3AssetUploadUrlInterceptor implements ExecutionInterceptor {
@Override
public SdkHttpResponse modifyHttpResponse(ModifyHttpResponse context, ExecutionAttributes executionAttributes) {
return context.httpResponse().toBuilder().putHeader("url", context.httpRequest().getUri().toString()).build();
}
} |
Resolved in #1134 |
The API is exposed through S3Utilities class. The API can be used in 2 ways:
|
How to let gradle to use the newest version? |
…7a5aead5 Pull request: release <- staging/72939def-6daf-4a11-a9bf-58427a5aead5
1.11.x had an operation for turning a bucket and object name into a URL. Equivalent functionality should be supported in 2.x.
The text was updated successfully, but these errors were encountered: