0

I have a resource called Media, which has a number of properties (Name, MediaType, MetaData, File). The Media resource also holds a pysical file. Now some of the details of the Media resource (MetaData), are gathered from the file. In my system, I am able to work in 2 ways.

1) Create a Media resource, setting Name and MediaType, then post a File to it (which updates the meta data).

I currently have this working in my web service as follows:

POST /rest/media (Creates and returns a Media resource)
GET /rest/media/{id} (Gets a specific Media resource)
PUT /rest/media/{id}/file (Uploads the file, and updates the Media resource)
GET /rest/media/{id}/file (Gets the uploaded file)

2) Upload a file, which automatically creates a Media resource, setting the Name to the file name, and automatically working out the MediaType from the file extension.

This is the scenario I need help architecting. I'd like to support both methods, but am unsure how to map this to a RESTful URL structure.

I'm open to general "RESTful" suggestions, but if you have an specific suggestions based on OpenRasta, that would be ideal.

Matt Brailsford
  • 2,209
  • 3
  • 28
  • 40

1 Answers1

0

I have good news for you. Not only has this already been designed for you, it's also a standard that has been implemented by many existing clients and servers: http://bitworking.org/projects/atom/rfc5023.html#media-link-entries

Darrel Miller
  • 139,164
  • 32
  • 194
  • 243
  • That's great. However I have a problem when it comes to creating a folder, as this doesn't actually have a file, and as I understand it, you have to create a media entity by posting a file? – Matt Brailsford Dec 16 '10 at 15:57
  • @Matt Not sure what you mean by a folder. As far as Atom is concerned all you need to do is to send a stream of bytes to create a media resource. – Darrel Miller Dec 16 '10 at 16:37
  • I mean that in my scenario, Media can be a file, but can also represent a folder which doesn't have a file, so it wouldn't be possible to make just create a "media-link" – Matt Brailsford Dec 16 '10 at 21:42
  • @Matt An Atom entry could easily point to another feed which contains equivalent to the folder. I would be very surprised if you could not meet your requirements with an Atom Pub based solution. – Darrel Miller Dec 17 '10 at 00:16