SaketaChalamchala commented on code in PR #4987:
URL: https://github.com/apache/ozone/pull/4987#discussion_r1267406564


##########
hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/ObjectEndpoint.java:
##########
@@ -229,15 +229,42 @@ public Response put(
       Map<String, String> customMetadata =
           getCustomMetadataFromHeaders(headers.getRequestHeaders());
 
+      long signedChunksLength = -1;
+      boolean signed = false;
       if ("STREAMING-AWS4-HMAC-SHA256-PAYLOAD"
           .equals(headers.getHeaderString("x-amz-content-sha256"))) {
+        signed = true;
         body = new SignedChunksInputStream(body);
+        //signedChunksLength = body2.readHeader();
+        String decodedContentLength = headers.
+            getHeaderString("x-amz-decoded-content-length");
+        if (decodedContentLength != null) {
+          signedChunksLength = Long.parseLong(decodedContentLength);
+        } else {
+          OS3Exception os3Exception = newError(S3ErrorTable.INVALID_REQUEST,
+              keyPath);
+          os3Exception.setErrorMessage("An error occurred (Missing Header) " +
+              "when calling the PutObject/MPU PartUpload operation: " +
+              " Necessary header 'x-amz-decoded-content-length' missing");
+          throw os3Exception;
+        }
       }
 
       output = getClientProtocol().createKey(volume.getName(), bucketName,
           keyPath, length, replicationConfig, customMetadata);
       getMetrics().updatePutKeyMetadataStats(startNanos);
       long putLength = IOUtils.copyLarge(body, output);
+
+      if ((signed ? signedChunksLength : length) != putLength) {
+        delete(bucketName, keyPath, uploadID);
+        OS3Exception os3Exception = newError(S3ErrorTable.INVALID_LENGTH,
+            keyPath);
+        os3Exception.setErrorMessage("An error occurred (InvalidLength) " +
+            "when calling the PutObject/MPU PartUpload operation: " +
+            " Body size does not match the expected length");

Review Comment:
   I don't think you need to overrite the error message here since it's already 
set in S3ErrorTabe.java



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to