My current task is to create a REST service that can be used to convert from one type of media to another (for example, from video / x-msvieo to video / x-flv). It cannot be used for browser. Typically, I allow POST clients to download media files and return them a URL for future use (for example, http://www.example.com/Media/12345 ).
The interesting thing is that when questions arise, the conversion process can be interpreted in two different ways:
1) The converted media is just another representation of the source, so to request the media in a new format, you can simply GET http://example.com/Media/12345 , and tell the service in the Accept-header that you need the format. Since when converting, for example, a large video, the service will respond with 202 Accepted until the conversion is complete. But what should happen if the conversion is not for any reason?
2) Since the conversion takes such a long time, one could imagine the process as its own resource. In this case, you would need to POST to describe some form of job description (possibly xml) at http://example.com/Media/12345 , and the service will respond with new URIs for the requested conversion (for example, http://example.com / Media / 12345 / jobs / 1 ). But wouldn't such a design be anything but a REST-linke?
I currently have:
1.) Download the media file at http://example.com/Media
2.) Answer: 201 Created / Location: http://example.com/Media/12345
3.) GET http://example.com/Media/12345
4.) Answer: 200 Ok and xml:
<media id="123457"> <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://example.com/Media/12345/video/x-flv">video/x-flv</link> <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://example.com/Media/12345/video/mpeg">video/mpeg</link> </media>
The links in xml send you the conversion goals available for this medium.
5.) Select from the links in xml to start the conversion / get the result using GETting http://example.com/Media/12345/video/mpeg
6.) Answer: 202 Accepted / Location: http://example.com/Media/12345/video/mpeg/Status
7.) Repeat step 5 until the conversion is complete or look at http://example.com/Media/12345/video/mpeg/Status to see what is currently happening.
So thank you very much for reading all this stuff :)
What do you think of my approach? What would you do differently? I am completely new to this, so any suggestions are highly appreciated.
Regards: Bill