rishabhdaim commented on code in PR #2558:
URL: https://github.com/apache/jackrabbit-oak/pull/2558#discussion_r2422572487


##########
oak-blob-cloud/src/main/java/org/apache/jackrabbit/oak/blob/cloud/s3/S3Backend.java:
##########
@@ -1276,22 +1253,24 @@ private void renameKeys() throws DataStoreException {
             } catch (InterruptedException ie) {
 
             }
-            LOG.info("Renamed [{}] keys, time taken [{}]sec", count,
-                ((System.currentTimeMillis() - startTime) / 1000));
+            LOG.info("Renamed [{}] keys, time taken [{}]sec", count, 
((System.currentTimeMillis() - startTime) / 1000));
             // Delete older keys.
             if (!deleteList.isEmpty()) {
                 RemoteStorageMode mode = (RemoteStorageMode) 
properties.getOrDefault(S3Constants.MODE, RemoteStorageMode.S3);
                 if (mode == RemoteStorageMode.S3) {
-                    DeleteObjectsRequest delObjsReq = new DeleteObjectsRequest(
-                            bucket);
                     int batchSize = 500, startIndex = 0, size = 
deleteList.size();
                     int endIndex = Math.min(batchSize, size);
                     while (endIndex <= size) {
-                        
delObjsReq.setKeys(Collections.unmodifiableList(deleteList.subList(
-                                startIndex, endIndex)));
-                        DeleteObjectsResult dobjs = 
s3service.deleteObjects(delObjsReq);
+                        int finalStartIndex = startIndex;
+                        int finalEndIndex = endIndex;

Review Comment:
   added in 
https://github.com/apache/jackrabbit-oak/pull/2558/commits/a52bd37b68f9e8f38967cf42511e374603a16f70



##########
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:
   added in 
https://github.com/apache/jackrabbit-oak/commit/a52bd37b68f9e8f38967cf42511e374603a16f70



-- 
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]

Reply via email to