Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
Timothy Spann committed Oct 5, 2018
1 parent 1ab0590 commit e50076f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<JsonNode> resp = Unirest.post(urlName)
.field(fieldName, stream, ContentType.parse(imageType), imageName).asJson();
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit e50076f

Please sign in to comment.