The HTTP protocol is ready to accept, from a client, a lot of data and/or large chunks of data, at once. A way to achieve this is to use a specific encoding type: multipart/form-data
. Such requests will have a body that can hold several data pieces formatted differently and attributed with different names. So, Play! 2 is a web framework that fits into HTTP as much as possible; that's why it deals with such requests goods, and provides an API that hides almost all of the tricky parts.
In this section, we'll see how one could upload an image along with some caption text that will be attached to a specific chat.
Before diving into the workflow, let's first create the holding structure: Image
.
This newly introduced type is not hard to understand as well; only two things should be pointed out: