Upload file using a Rapidminer Server Web App

Edin_KlapicEdin_Klapic Moderator, Employee, RMResearcher, Member Posts: 299 RM Data Scientist
edited November 2018 in Knowledge Base

Question

How can I upload a file (e.g. an Excel file) from my computer and process the results directly in RapidMiner Server?

Answer

Here is what you need:

 

  • RapidMiner Server up and running
  • The Text processing extension (on Server and on Studio)
  • Being able to create a Webservice from a RapidMiner process. See article How to create a webservice for details.

 

The solution in short:

 

  1. Create an HTML form which includes an input tag with type="file" and display it as a Web App visualization component
  2. Send the file via HTTP-Post to a RapidMiner process which has been published as a web service
  3. Store / Process the file and provide a success message

 

The solution in detail:

 

 

Spoiler

Hint

Using the special user "anonymous" makes the functionality much more convenient. This way the user who uploads the file does not need to reauthenticate himself for the upload. Therefore "anonymous" needs to have at least permission to execute within the folder in which the described processes are stored. See article Create and Manage "Special Users"  for further information.
In this case you need to grant the user anonymous the execute permissions for the folder where the processes are stored. If you want to store data, the user also needs the permission to write.
In addition you need to adapt the action URL. You need to include the keyword "public" between "rest" and "process" (http://localhost/api/rest/public/process/<web service name>)

 

  1. Create a folder in which you want to store the processes (and uploaded data if you wish) on the server.
  2. Now create the process which receives the uploaded file and processes it. The attached example process "Read file from web app - webservice" receives either one or two excel file(s) and stores them in the repository. Then it sends a success message.
  3. This process needs to be exported as webservice as described in the article How to create a webservice. Make sure that you have set the Output format to "HTML" and the MIME Type to "text/html".
  4. Create the process displaying the HTML form and set the Webservice URL as the value for the form "action" (see attached example process).
  5. Create the Upload component as "New visualization" component in your RapidMiner Server Web App.
  6. Make sure that you have set the Output format to "HTML" and the MIME Type to "text/html".

 

 

What are constraints of this feature?

  • If you enable the upload of multiple files at once (by using the keyword "multiple" in the HTML tag for the the input type="file") and you want to store them as one exampleset you have to ensure that the structure of the uploaded files is the same.
  • You can only upload as many files at once as you have input ports connected.
  • The operator "Publish to App" does not work in webservices since it is executed in a different session.

 

 Edit (2016/12/15):

I just uploaded new process versions which already store each uploaded file with the original name as well as the full file.

The webservice now also makes use of the Handle Exception Operator which helps you to deal with problems.

Edit (2016/12/16):

I just uploaded a new process version for the HTML form. It includes a version of the HTML form with which you can rename the file(s) you upload. Only works for single file uploads.

 

Output of example process "Read file from web app - HTML form"

 

Upload Component.PNG

 If you have selected a file for upload - the name is displayed

 

Upload Component - file selected.PNG

 

 Success message (output of the example process "Read file from web app - webservice")

 

Upload Component - success.PNG

Comments

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

    This is GREAT.  Thank you so much for posting this.  I have just installed it and it works very well.  One small question - how can I pass the Excel file name into the process so that it stores the data set using this name, rather than the "Uploaded file".  Or, even better, can there be a small dialog box that asks for the name for the new data set? before Start Upload?

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

    Glad I could help. :)

     

    I just uploaded new versions of the processes which store the original files as repository examplesets and the full (i.e. appended) file.  :)

     

    Including a dialog box should be possible in the HTML form. I will check and let you know, how this can be achieved.

     

    Best,

    Edin

     

     

  • icsd11159icsd11159 Member Posts: 16 Maven

    Hello,

    thank you for your post! But i face a problem . I paste the Embeddable HTML Code in action (html app) but when I test the web app - webservice.rmp with web service(RM Server)i get error: 

    de.rapidanalytics.ejb.service.ServiceDataSourceException: Error executing process /home/admin/Read file from web app - HTML form.rmp for service newServiceupload: The dummy operator Create Document (replacing text:create_document) cannot be executed.

    and nothing is work !

    Thank you in advance

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

    hello @icsd11159 so when you get a "dummy operator" that means that RapidMiner does not recognize the operator. In this case it is highly likely that the Text Processing extension is not installed on your server.

  • icsd11159icsd11159 Member Posts: 16 Maven

    Thnak you for your reply!

    I try to add the extension in System Settings like thisex.PNG

    But nothing is change.

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

    Hello @icsd11159 - yes that's not correct. Here's the link to documentation on installing extensions on Server: https://docs.rapidminer.com/latest/server/administration/installing-extensions.html

     

    Scott

     

  • mbslsmbsls Member Posts: 6 Contributor II
    Hello! @spenzer @Edin_Klapic . I would like to ask you about how can I upload image file? Specifically, how can I create the process which receives an uploaded file and processes it? I am using the operator Open color image for my process and I am trying to set the path to the "filename" field. When I am using RM server the message I get is "The file 'filename' does not exist".
  • sgenzersgenzer Administrator, Moderator, Employee, RapidMiner Certified Analyst, Community Manager, Member, University Professor, PM Moderator Posts: 2,959 Community Manager
    edited February 2020
    hi @mbsls welcome to the community. So there are a few pieces here...

    - re uploading files: I would use AWS S3 or similar as a repo for receiving uploaded files (rather than what is suggested here which is quite old). Then I would use Read Amazon S3 or similar to grab + process. It's just not good practice to receive lots of files on the same server as your execution server.

    - I assume you are trying to do this with the Image Mining extension? This extension was built by a 3rd party many years ago and is no longer supported (see http://burgsys.com/image-analysis-software.php)

    Scott
  • mbslsmbsls Member Posts: 6 Contributor II
    Thank you very much for your answer and for the quick reply!! Yes, I am trying to do this with the Image Mining extention. The second operation that I am using  after open color image is statistical region mergin which takes as input, color image. I am new here and I don't know how to use Read Amazon S3  to create the process which will give me the path to receive the uploaded image file from the web app. 
Sign In or Register to comment.