RapidMiner

Best way to POST a file?

Wisdom logo Registration now open for RapidMiner Wisdom Americas | New Orleans | October 10-12, 2018   Learn More
Unicorn
Unicorn

Best way to POST a file?

Hi guys,

 

I want to take the binary data file of an image and upload via POST multipart/form-data to a webservice, then consume the (JSON) result.  

 

This should be possible with lots of writing in Groovy or Python, but is it possible in either the GetPage or EnrichData by WebService operators? 

 

 

-- Training, Consulting, Sales in China, Hong Kong & Taiwan --
www.RapidMinerChina.com
2 REPLIES
RM Staff RM Staff
RM Staff

Re: Best way to POST a file?

Hi John,

 

I am not 100% sure if I get you correct but this should work with the File Upload functionality described in this Knowledge base article. The upload functionality is not limited to MIME type Excel or CSV. 

You could also use curl. For Enrich Data by Webservice the image needs to be in the body of the message.

 

Hope this helps.

 

Best,

Edin

------------------------------------------------------------------------------------------------------------
How can I share my RapidMiner Process?
Where do I find the Logfile of RapidMiner Studio?
Where do I find the Logfile of RapidMiner Server?
Where do I find the Logfile of a RapidMiner Server Job Agent?
Where do I find the Logfile of a Process executed on a RapidMiner Server Job Agent?
------------------------------------------------------------------------------------------------------------
Community Manager Community Manager
Community Manager

Re: Best way to POST a file?

hi...I have tried to do something very similar with the Zamzar API where I am uploading a PDF binary.  I use cURL instead of Enrich Data via Webservice as the latter did not work well for me.  Here's my code - hopefully you will see what I was doing and adapt to your issue.

 

<?xml version="1.0" encoding="UTF-8"?><process version="7.5.003">
  <context>
    <input/>
    <output/>
    <macros/>
  </context>
  <operator activated="true" class="process" compatibility="7.5.003" expanded="true" name="Process">
    <process expanded="true">
      <operator activated="true" class="productivity:execute_program" compatibility="7.5.003" expanded="true" height="103" name="Execute Program" width="90" x="45" y="34">
        <parameter key="command" value="sudo curl -u 11111: -X POST -F &quot;source_file=@/Users/GenzerConsulting/Desktop/foo.pdf&quot; -F &quot;target_format=html5&quot; https://sandbox.zamzar.com/v1/jobs"/>
        <parameter key="working_directory" value="/Users/GenzerConsulting/Desktop"/>
        <list key="env_variables"/>
      </operator>
      <operator activated="true" class="text:read_document" compatibility="7.5.000" expanded="true" height="68" name="Read Document" width="90" x="179" y="34"/>
      <operator activated="true" class="text:json_to_data" compatibility="7.5.000" expanded="true" height="82" name="JSON To Data" width="90" x="313" y="34"/>
      <connect from_op="Execute Program" from_port="out" to_op="Read Document" to_port="file"/>
      <connect from_op="Read Document" from_port="output" to_op="JSON To Data" to_port="documents 1"/>
      <connect from_op="JSON To Data" from_port="example set" to_port="result 1"/>
      <portSpacing port="source_input 1" spacing="0"/>
      <portSpacing port="sink_result 1" spacing="0"/>
      <portSpacing port="sink_result 2" spacing="0"/>
    </process>
  </operator>
</process>

 

Scott

Scott Genzer
Senior Community Manager
RapidMiner, Inc.