What good timing, I just did : https://github.com/apache/nifi/pull/4234
If you can build and try that would be sweet!  or maybe a review!

On April 27, 2020 at 13:45:42, Etienne Jouvin (lapinoujou...@gmail.com)
wrote:

Hello.

I did it with a processor ExecuteGroovyScript.

The script body is something like :

import org.apache.http.entity.mime.MultipartEntityBuilder
import org.apache.http.entity.ContentType

flowFileList = session.get(100)
if(!flowFileList.isEmpty()) {
  flowFileList.each { flowFile ->
    def multipart
    String text = flowFile.read().getText("UTF-8")

    flowFile.write{streamIn, streamOut->
      multipart = MultipartEntityBuilder.create()
        //specify multipart entries here
        .addTextBody("object", text, ContentType.APPLICATION_JSON)
        .addBinaryBody("content", new
File(flowFile.'document.content.path'),
ContentType.create(flowFile.'document.mime.type'), flowFile.'document.name')
        .build()
      multipart.writeTo(streamOut)
    }
    //set the `documentum.action.rest.content.type` attribute to be used as
`Content-Type` in InvokeHTTP
    flowFile.'document.content.type' = multipart.getContentType().getValue()
    session.transfer(flowFile, REL_SUCCESS)
  }
}


Attributes are :

   - document.content.path : content path
   - document.mime.type : content mime type
   - document.name : binaire content name


Output update attribute
document.content.type : multipart content type.

You need some extra librairies :

   - httpcore-4.4.12.jar
   - httpmime-4.5.10.jar


This will build a multipart as the flowfile content and you can use it for
the call after.


Etienne


Le lun. 27 avr. 2020 à 19:21, Luis Carmona <lcarm...@openpartner.cl> a
écrit :

> Hi everyone,
>
> Hoping everybody is doing ok, wherever you are, need some help please.
>
> Does anyone has sent a file and parameters to a REST point using
> Invokehhtp with multipart/form-data as mime-type ?
>
> I can't figure out how to include the -F <parameter>, speaking in terms
> of curl syntax.
>
> I really need this done throught NIFIso any help will be highly
> apreciated.
>
> Thanks in advance.
>
> LC
>
>

Reply via email to