The Semi-Rookie Rides Again - Http Post an image?

Hi all,

I would like to take an image from my database and move it to a public URL where another application is going to grab it.

Now, I think that the way to do this would be to use the http plugin and then create a POST. However, I’m unsure how to specify a database element with setBodyContent, and I’m also unsure whether I can just send an image “as is” that way, or whether it needs to be manipulated some way in order to accomplish the POST and still have the image be useful on the other end. I’m also waiting to hear back from the folks with the other application to see if the image needs to be encapsulated in some way since there is some other data that needs to go along so that they know where to put the image.

As always, any guidance would be appreciated.

Thanks and have a good day.

Ron

You need to create a web service for this, not use the http plugin: the http plugin acts as a client, in your case you want to act as a server…

The easiest way will be to use the Velocity plugin, where you will be able to define a simple ByteResponse giving it the bytes of the image you want to publish (plugins.Velocity.createByteResponse() or plugins.Velocity.createFileResponse()).

Have a look at the Velocity plugin at ServoyForge: https://www.servoyforge.net/projects/velocity-report and the Wiki about the Velocity plugin: https://www.servoyforge.net/projects/ve … onseObject - try the demo VelocityWebClient solution and you will see that it’s very easy to do.

Also if you need to encapsulate the image, you will probably need to encode it using Base64 (for JSON or XML web service).