Member since
12-10-2019
11
Posts
1
Kudos Received
0
Solutions
05-20-2021
06:17 AM
1 Kudo
Not all credit goes to me but I was pointed to a better simpler way to achieve this. There are 2 ways. Solution 1 - and the simplest and elegant Use Nifi JoltTransformJSON Processor. The processor can make use of Nifi expression language and attributes in both left or right hand side of the specification syntax. This allows you to quickly use the JOLT default spec to add new fields (from flow-file attributes) to a new or existing JSON. Ex: {"customer_id": 1234567, "vckey_list": ["test value"]} both of those fields values are stored in flow-file attributes as a result of a EvaluateJSONPath operation. Assume "customer_id_attr" and ""vckey_list_attr". We can simply generate a new JSON from those flow-file attributes with the "default" jolt spec and the right hand syntax. You can even add addition expression language functions to the processing [
{
"operation": "default",
"spec": {
"customer_id": ${customer_id_attr},
"vckey_list": ${vckey_list_attr:toLower()}
}
}
] This worked for me even when storing the entire JSON, path of "$", in a flow-file attribute. Solution 2 - complicated and uglier Use a sequence Nifi ReplaceText Processor. First use a ReplaceText processor to append the desired flow-file attribute to the file-content. If you are generating a totally new JSON, this would do it. If you are trying to modify an existing one, you would need to first append the desired keys, than use ReplaceText again to properly format as a new key in the existing JSON, from {"original_json_key": original_json_obj}{"customer_id": 1234567, "vckey_list": ["test value"]} to {"original_json_key": original_json_obj, "customer_id": 1234567, "vckey_list": ["test value"]} using Then use JOLT to do further processing (that's why Sol 1 always makes sense) Hope this helps, spent about half a day figuring out the 2nd Solution and was pointed to Solution 1 by someone with more experience in Nifi
... View more
02-04-2020
09:52 AM
@lueenavarro Using a key that has no password protection is bad security. This is why the processor requires a password to protect that key. Adding a password to the key you were provided does not alter the key nor does it require you to obtain a new key in order to add a password. Only other option i can suggest is to use an ExecuteStreamCommand or ExecuteScript processor to to execute the SFTP command with your password-less key to put content to your SFTP server. Hope this helps, Matt
... View more
12-24-2019
03:20 AM
This is more a Python question than a Nifi one, perhaps this will help: import pyminizip
pyminizip.compress("myfile.txt", "myzippedfile.zip", "mypassword", compression_level) I would recommend you to first see if you can get the python part working, and then worry about how to call it from Nifi.
... View more