mbaedke commented on code in PR #2558:
URL: https://github.com/apache/jackrabbit-oak/pull/2558#discussion_r2419714284
##########
oak-blob-cloud/src/main/java/org/apache/jackrabbit/oak/blob/cloud/s3/S3Backend.java:
##########
@@ -1022,134 +1026,102 @@ record = new S3DataRecord(
return record;
}
- private URI createPresignedURI(DataIdentifier identifier,
- HttpMethod method,
- int expirySeconds) {
- return createPresignedURI(identifier, method, expirySeconds, new
HashMap<>());
+ private URI createPresignedURI(DataIdentifier identifier, int
expirySeconds) {
+ return createPresignedURI(identifier, SdkHttpMethod.PUT,
expirySeconds, new HashMap<>());
}
private URI createPresignedURI(DataIdentifier identifier,
- HttpMethod method,
+ SdkHttpMethod method,
int expirySeconds,
Map<String, String> reqParams) {
final String key = getKeyName(identifier);
+ // SSE-C is supported with presigned URLs when encryption headers are
included in both
+ // the signature calculation (handled by S3RequestDecorator) and the
actual HTTP request
+
try {
final Date expiration = new Date();
- expiration.setTime(expiration.getTime() + expirySeconds * 1000);
+ URL presignedURL = null;
+ expiration.setTime(expiration.getTime() + expirySeconds * 1000L);
- GeneratePresignedUrlRequest request = s3ReqDecorator.decorate(new
GeneratePresignedUrlRequest(bucket, key)
- .withMethod(method)
- .withExpiration(expiration));
+ // Add raw query parameters via override configuration
+ AwsRequestOverrideConfiguration.Builder overrideBuilder =
AwsRequestOverrideConfiguration.builder();
for (Map.Entry<String, String> e : reqParams.entrySet()) {
- request.addRequestParameter(e.getKey(), e.getValue());
+ overrideBuilder.putRawQueryParameter(e.getKey(), e.getValue());
+ }
+
+ switch (method) {
+ case GET:
+ presignedURL = s3PresignService.presignGetObject(builder
-> builder
+ .signatureDuration(Duration.between(
+ Instant.now(), // current time
+ expiration.toInstant() //
expiration time from your Date object
+ ))
+ .getObjectRequest(s3ReqDecorator.decorate(
+ GetObjectRequest.builder()
+ .bucket(bucket)
+ .key(key)
+
.overrideConfiguration(overrideBuilder.build())
+ .build()))
+ .build()).url();
+ break;
+ case PUT:
+
+ presignedURL = s3PresignService.presignPutObject(builder
-> builder
+ .signatureDuration(Duration.between(
+ java.time.Instant.now(), //
current time
Review Comment:
No need to qualify.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]