If you’re using Pentaho BI Server for a while, you’ve probably needed to provide some upload capabilities. Sometimes we need to make a helper app to enable features for key-users; sometimes you’re developing a plugin and need an uploader.
So far, what you’d need to do is to develop a Java endpoint that would consume a POST multipart/form-data request and do the dirty job. Then, for each different thing you’d want to do with the file you uploaded, you’d need to code it. This also means bundling a jar and deploying it to the right place.
Tapa is a login page customizer for BI Server that also does a lot of other UI customizations – we’ll write about this later here. When we were developing it, we needed that uploader for bringing to the admin user that would customize its templates, the ability to upload images and to upload templates to the server.
With this in mind, we thought it would be good to do this uploader in a very flexible fashion.
Usually, when you need to upload a file, you want to send it somewhere in your server and then do some post-upload-processing with it, right? Sometimes you just want to copy it somewhere else or to extract some information out of it.
So who better to do such post-upload processing than Pentaho Data Integration?
With this in mind, that’s our uploader: upload-then-endpoint. It uploads a file to a certain location into the server – tomcat/temp – and then calls an endpoint passing down the file path and any more parameters you want.
This component is meant to be used within a plugin you’re developing – we also thought about developing a minimalistic plugin to wrap it, but we don’t know if it’s worth it.
So, to use this guy in your plugin, you should only:
- copy our JAR
oncase-biserver-uploader-X.X.X.jarto your plugin lib folder and then – find it here;
- add the following line to your
plugin.spring.xml, after the
After doing this, you just need to restart your bi-server and you should be ready to go.
You can now upload your files and tell the uploader which endpoint you want to call next and what parameters to forward.
The multipart/form-data POST should be sent to
/pentaho/plugin/YOU_PLUGIN_ID/api/upload/send and this endpoint accepts the parameters:
* file – The file that will be uploaded;
* endpointPath – The path to the endpoint that will be called after the upload is done. This path is relative to the contextPath (after the …:8080/pentaho/) ex.:
* queryParameters – Any queryparameters you’d want to forward to your endpoint. ex.:
There are some example files inside of
resources/ folder – here.
Well, that’s it.
We hope it’s going to be useful for somebody out there. :)