vefmotor.blogg.se

Sending base64 encoding with json
Sending base64 encoding with json













sending base64 encoding with json

If you need to just encode one of the JSON objects, then if it is in an attribute you can use UpdateAttribute with the base64Encode Expression Language function, or if it is in content you can use the Base64EncodeContent processor. I has a fairly standard method that base64-encodes a string prior to sending that string over the wire to a client. Sometimes you have to send or output an image. However if one of them fits in a attribute, then you can use the UpdateRecord or ReplaceText processor as described. Convert image to Base64 online and use the result string as data URI, img src, CSS background-url, and others. Note that attributes have limited size and introduce more memory usage, so beware of large JSON objects in attributes. If you have binary data that you need to encode to pass to the client as JSON, you can convert it to base64, a common means on the Internet to represent. Alternative solution would be encoding stuff on the fly with a custom encoder: import json from base64 import b64encode class Base64Encoder(json.JSONEncoder): pylint: disablemethod-hidden def default(self, o): if isinstance(o, bytes): return b64encode(o). Whichever of the two (from AttributesToJSON or FetchFTP) is smaller, you can get that object first and use ExtractText to put the whole thing into an attribute. However one of the two JSON objects must be in an attribute. You can also do this manually with ReplaceText. Data is limited in size to 128 or fewer decoded bytes. In NiFi 1.3.0, you can use UpdateRecord to add the JSON from an attribute into a field in the other JSON document. encoding: string - encoding for filter bytes data, either base58 or base64. If you have too many attributes for that, your options are a bit more limited. If the incoming file (from FTP) is JSON, and you can get your attributes added to that flow file, then (as of NiFi 1.2.0 / HDF 3.0) you can use JoltTransformJSON to inject your individual attributes as fields into your JSON document (instead of AttributesToJSON). What do you mean by "add to this JSON a file that I get from FetchFTP"? Is the file you're fetching a JSON file, and you want to add fields to it? Are you Base64 encoding just the JSON from the attributes or the entire file after adding to it?















Sending base64 encoding with json