Hi,

I am working to implement a flow where we need to POST some data to another 
system using multipart/form-data. This system requires that one of the form 
fields acts as an attached file. Using curl, this works fine:

curl -F <field1>=<data1> -F <field2>=<data2> -F <field3>=@[filename] <URL>

I created a flowfile that mimics what curl sends, including the boundaries etc. 
Using InvokeHTTP POST I receive a web-server error from the receiving end that 
mentions a missing parameter.

Running with curl --trace-ascii or POSTing to a running netcat with both curl 
and nifi shows exactly the same results, with the exception of the actual 
boundary marker (which is always different) and some minor header stuff (UA, 
etc.) The payload is simple text. 

I understand that there is some difference between sending the data and 
uploading a file, but am unable to figure out what this is. for example, 
sending the same data with curl using -F<field3>=<[filename] (instead of 
@[filename]) also results in an error. 

I have read a few different messages about POSTing multipart-form data where 
files need to be uploaded, and most appear to end up with writing a scripted 
processor or invoking shell. This is particularly undesirable for us given the 
volume of files we must process, and the speed at which we should be uploading 
those files. 

Is there any way in which to mimic the uploading/attaching of a file, instead 
of sending the data as text?

Thanks

Martijn

Reply via email to