Search code examples
jsonapache-nifiunpack

Using NIFI how do you apply attributes to files in a zip from a json file also contained in the same zip?


Using Apache Nifi I'd like to process a zip which contains a category.json file and a number of data files as illustrated.

somefile.zip
├──category.json
├──datafile-1
├──datafile-2
├──...
├──datafile-n

Example category.json

{
  "category": "history",
  "rating" : 5 
}

What I'd like to do is unpack the files and apply the category.json data as attributes to each datafile.

What would be the best way to handle this problem?


Solution

  • Myabe not the best one, but a way to do it :

    1) unzip
    2) use routeOnAttribut based on category.json filename
    3) retrieve category as attribut in category.json flowfile
    4) zip all file again but keep atttribut
    5) unzip again and keep attribut, all your flowfile will have the category attribut