diff --git a/nifi-postimage-processors/src/main/java/com/dataflowdeveloper/processors/HTTPPostUtility.java b/nifi-postimage-processors/src/main/java/com/dataflowdeveloper/processors/HTTPPostUtility.java index d00d99b..8715f39 100644 --- a/nifi-postimage-processors/src/main/java/com/dataflowdeveloper/processors/HTTPPostUtility.java +++ b/nifi-postimage-processors/src/main/java/com/dataflowdeveloper/processors/HTTPPostUtility.java @@ -35,6 +35,10 @@ public static HTTPPostResults postImage(String urlName, String fieldName, String HTTPPostResults results = new HTTPPostResults(); + if ( urlName == null || fieldName == null || imageName == null || imageType == null || stream == null ) { + System.out.println("Nulls"); + return results; + } try { HttpResponse resp = Unirest.post(urlName) .field(fieldName, stream, ContentType.parse(imageType), imageName).asJson(); @@ -50,6 +54,8 @@ public static HTTPPostResults postImage(String urlName, String fieldName, String results.setHeader( resp.getHeaders().toString() ); results.setStatus(resp.getStatusText()); + System.out.println("results found"); + try { Unirest.shutdown(); } catch (IOException e) { diff --git a/nifi-postimage-processors/src/main/java/com/dataflowdeveloper/processors/PostImageProcessor.java b/nifi-postimage-processors/src/main/java/com/dataflowdeveloper/processors/PostImageProcessor.java index 2ac7271..0eb90d3 100644 --- a/nifi-postimage-processors/src/main/java/com/dataflowdeveloper/processors/PostImageProcessor.java +++ b/nifi-postimage-processors/src/main/java/com/dataflowdeveloper/processors/PostImageProcessor.java @@ -184,17 +184,24 @@ public void process(InputStream input) throws IOException { HTTPPostResults results = HTTPPostUtility.postImage(url, field, image, imgtype, input); if (results != null) { - getLogger().debug(String.format("Found %sresults", new Object[] { results.getStatus() })); - - attributes.put(ATTRIBUTE_OUTPUT_NAME, results.getJsonResultBody()); - attributes.put(ATTRIBUTE_OUTPUT_HEADER, results.getHeader()); - attributes.put(ATTRIBUTE_OUTPUT_STATUS, results.getStatus()); + try { + getLogger().debug(String.format("Found %sresults", new Object[] { results.getStatus() })); + + System.out.println("Status=" + results.getStatus()); + attributes.put(ATTRIBUTE_OUTPUT_NAME, results.getJsonResultBody()); + attributes.put(ATTRIBUTE_OUTPUT_HEADER, results.getHeader()); + attributes.put(ATTRIBUTE_OUTPUT_STATUS, results.getStatus()); + } catch (Exception e) { + e.printStackTrace(); + } } } }); if (attributes.size() == 0) { + System.out.println("Errors"); session.transfer(flowFile, REL_FAILURE); } else { + System.out.println("count:" + attributes.size()); flowFile = session.putAllAttributes(flowFile, attributes); session.transfer(flowFile, REL_SUCCESS); }