turcsanyip commented on code in PR #8295:
URL: https://github.com/apache/nifi/pull/8295#discussion_r1466940824


##########
nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/s3/PutS3Object.java:
##########
@@ -501,6 +508,8 @@ public void onTrigger(final ProcessContext context, final 
ProcessSession session
         final FlowFile ff = flowFile;
         final Map<String, String> attributes = new HashMap<>();
         final String ffFilename = 
ff.getAttributes().get(CoreAttributes.FILENAME.key());
+        final ResourceTransferSource resourceTransferSource = 
ResourceTransferSource.valueOf(context.getProperty(RESOURCE_TRANSFER_SOURCE).getValue());

Review Comment:
   Please use the recently added `PropertyValue.asAllowableValue()` method:
   ```suggestion
           final ResourceTransferSource resourceTransferSource = 
context.getProperty(RESOURCE_TRANSFER_SOURCE).asAllowableValue(ResourceTransferSource.class);
   ```



##########
nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/s3/PutS3Object.java:
##########
@@ -517,331 +526,328 @@ public void onTrigger(final ProcessContext context, 
final ProcessSession session
         /*
          * Then
          */
-        try {
-            final FlowFile flowFileCopy = flowFile;
-            session.read(flowFile, new InputStreamCallback() {
-                @Override
-                public void process(final InputStream in) throws IOException {
-                    final ObjectMetadata objectMetadata = new ObjectMetadata();
-                    objectMetadata.setContentLength(ff.getSize());
-
-                    final String contentType = 
context.getProperty(CONTENT_TYPE)
-                            .evaluateAttributeExpressions(ff).getValue();
-                    if (contentType != null) {
-                        objectMetadata.setContentType(contentType);
-                        attributes.put(S3_CONTENT_TYPE, contentType);
-                    }
+        final FlowFile flowFileCopy = session.clone(flowFile);

Review Comment:
   I don't think we need to clone the FlowFile. What is the reason for that?



##########
nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/s3/PutS3Object.java:
##########
@@ -852,25 +858,27 @@ public void process(final InputStream in) throws 
IOException {
             final long millis = 
TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startNanos);
             session.getProvenanceReporter().send(flowFile, url, millis);
 
-            getLogger().info("Successfully put {} to Amazon S3 in {} 
milliseconds", new Object[] {ff, millis});
+            getLogger().info("Successfully put {} to Amazon S3 in {} 
milliseconds", new Object[]{ff, millis});
             try {
                 removeLocalState(cacheKey);
             } catch (IOException e) {
                 getLogger().info("Error trying to delete key {} from cache: 
{}",
                         new Object[]{cacheKey, e.getMessage()});
             }
-        } catch (final ProcessException | AmazonClientException pe) {
+
+        } catch (final ProcessException | AmazonClientException | IOException 
pe) {

Review Comment:
   ```suggestion
           } catch (final ProcessException | AmazonClientException | 
IOException e) {
   ```



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