In this first week, I've implemented two methods for the Media Server HTTP API (with tests):
Once the main idea right now is prototyping, both methods doesn't have authentication yet, but is possible to publish the media server into a web server and have simple upload/download functions.
GET /channel/{channelId}/media/{mediaId}
POST /channel/{channelId}/media
Also, a JSON representation of the Media was defined:
{ "id": string, "uploader": string, "title": string, "mimeType": string, "description": string, "uploadedDate": datetime, "lastViewedDate": datetime, "downloadUrl": string, "fileExtension": string, "md5Checksum": string, "fileSize": long, "length": long, // for videos "height": int, // for videos and images "width": int // for videos and images }In this way, when a client tries to upload a media, it has to provide two fields at the multipart/form-data (more fields can be added later, for authentication as example). The body field, that will have the media json representation and the binaryFile field that will have the file content:
-----Aa1Bb2Cc3--- Content-Disposition: form-data; name="body"; filename="" Content-Type: application/json; charset=UTF-8 {"fileExtension":"jpg","md5Checksum":"cd1b78e4686ae1a3cfb461a1085545f0","width":312,"uploader":"user@domain.com", "downloadUrl":null,"id":"testFileId","fileSize":60892,"title":"testimage.jpg","height":312,"description":"a description","length":null,"mimeType":"application/octet-stream","lastViewedDate":null,"uploadedDate":null} -----Aa1Bb2Cc3--- Content-Disposition: form-data; name="binaryFile"; filename="testimage.jpg" Content-Type: image/jpeg ...file content... -----Aa1Bb2Cc3-----
When the server receives the file, it makes some verifications, like: MD5 checksum matching, file size matching, etc.
On the other side, we have the download method, it simple returns the requested file with the {mediaId} passed as argument.
The next steps are:
- Implement methods to upload/download channel's and user's avatars;
- Implement the XMPP component;
- Implement full upload/download for public channels functionality.