1

i write a nifi custom processor that handle xlsx to csv , and in my code i generate a string csv like this from xlsx, but i don“t know how to send it as csv, and the other processors like inferavroschema from csv can recognize the inpustream as csv.

final AtomicReference<String> value = new AtomicReference<>();

String csvToString= "
name,age,info
javo,23,wasa
pepe,34,lima"

value.set(csvToString);

And in my code i send it in this way, but when i see the data provenance it apears as content type text:

String results = value.get();
       if(results != null && !results.isEmpty()){
           flowFile = session.putAttribute(flowFile, "csv", results);
       }
       flowFile = session.write(flowFile, new OutputStreamCallback() {
           @Override
           public void process(OutputStream out) throws IOException {
               out.write(value.get().getBytes());
           }
       });
       session.transfer(flowFile, SUCCESS);
javier_orta
  • 457
  • 4
  • 15

1 Answers1

2

The attribute name for content type in nifi named mime.type

So, you have to set its value to csv.

flowFile = session.putAttribute(flowFile, "mime.type" "csv");
daggett
  • 26,404
  • 3
  • 40
  • 56