You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by GitBox <gi...@apache.org> on 2020/11/11 16:14:28 UTC

[GitHub] [nifi-minifi-cpp] lordgamez commented on a change in pull request #931: MINIFICPP-1390 Create DeleteS3Object processor

lordgamez commented on a change in pull request #931:
URL: https://github.com/apache/nifi-minifi-cpp/pull/931#discussion_r521469706



##########
File path: extensions/aws/s3/S3Wrapper.cpp
##########
@@ -38,8 +38,24 @@ minifi::utils::optional<Aws::S3::Model::PutObjectResult> S3Wrapper::sendPutObjec
       logger_->log_info("Added S3 object %s to bucket %s", request.GetKey(), request.GetBucket());
       return outcome.GetResultWithOwnership();
   } else {
-      logger_->log_error("PutS3Object failed with the following: '%s'", outcome.GetError().GetMessage());
-      return minifi::utils::nullopt;
+    logger_->log_error("PutS3Object failed with the following: '%s'", outcome.GetError().GetMessage());
+    return minifi::utils::nullopt;
+  }
+}
+
+bool S3Wrapper::sendDeleteObjectRequest(const Aws::S3::Model::DeleteObjectRequest& request) {
+  Aws::S3::S3Client s3_client(credentials_, client_config_);
+  Aws::S3::Model::DeleteObjectOutcome outcome = s3_client.DeleteObject(request);
+
+  if (outcome.IsSuccess()) {
+    logger_->log_info("Deleted S3 object %s from bucket %s", request.GetKey(), request.GetBucket());
+    return true;
+  } else if (outcome.GetError().GetErrorType() == Aws::S3::S3Errors::NO_SUCH_KEY) {
+    logger_->log_info("S3 object %s was not found in bucket %s", request.GetKey(), request.GetBucket());

Review comment:
       In NiFi the processor's [description](https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi/nifi-aws-nar/1.5.0/org.apache.nifi.processors.aws.s3.DeleteS3Object/index.html) says "If attempting to delete a file that does not exist, FlowFile is routed to success". It's a bit strange to me as well, but I wanted to be consistent with the Nifi implementation. We could change it in our case if you prefer.




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org