Thank you all,

Wesley and Etienne, is there any documentation source about how to
connect a script in javascript to nifi resources, InputStream,
OutputStream, Erros, and so on ?


Otto, sure I can give it a try, I am desperate for this solution. What
you mention means I have to look for a tutorial about adding a custom
processor right ?


Thanks again,

LC




On Mon, 2020-04-27 at 14:52 -0300, Wesley C. Dias de Oliveira wrote:
> Owh!
> 
> Great, Otto!
> 
> Good news!
> 
> Em seg., 27 de abr. de 2020 às 14:50, Otto Fowler <
> [email protected]> escreveu:
> > 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 (
> > [email protected]) 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 <
> > > [email protected]> 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