Forward Vaadin UploadReceiver to another REST Endpoint

Hi All,

I have a need to pass on a file uploaded in Vaadin to another REST API. The uloaded file will come through the UploadReceiver I’m guessing. So can anyone point me in the right direction to forward the file on, prefferably without having to write the whole file before forwarding.

Thanks all.

Use Upload.setReceiver() to set a receiver that returns an output stream that just forwards the data as it comes, ideally with a small buffer e.g. by wrapping your stream in a BufferedOutputStream. Note that some of the data might still get kept somewhere by the server or by Vaadin Framework temporarily due to encodings etc.

Hi. Thanks for your reply. I understand what you are saying it but I’m not sure how toimplement it. The examples of the Upload.setReceiver() seem to create a file and return the output stream to write to it. Are you saying that I need to create a POST Request in the Upload.setReceiver() and the output stream should feed the request? Sorry I’m just a bit lost on tying up the output stream of the upload to the post resuest to forward the data on

More or less, yes - your Receiver.receiveUpload() can start the request and start streaming whatever is written to the OutputStream you return from it to the POST content. How to do it depends on your REST client - see e.g.
this SO thread

Disclaimer: I haven’t tested this.