The Altair Community is migrating to a new platform to provide a better experience for you. In preparation for the migration, the Altair Community is on read-only mode from October 28 - November 6, 2024. Technical support via cases will continue to work as is. For any urgent requests from Students/Faculty members, please submit the form linked here

Best way to POST a file?

JEdwardJEdward RapidMiner Certified Analyst, RapidMiner Certified Expert, Member Posts: 578 Unicorn
edited October 2019 in Help

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? 

 

 

Answers

  • Edin_KlapicEdin_Klapic Employee-RapidMiner, RMResearcher, Member Posts: 299 RM Data Scientist

    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

  • sgenzersgenzer Administrator, Moderator, Employee-RapidMiner, RapidMiner Certified Analyst, Community Manager, Member, University Professor, PM Moderator Posts: 2,959 Community Manager

    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

Sign In or Register to comment.