We are implementing de REST API with resources names "files".
/api/files.json returns the list of files such as user pictures, blog posts attachments, etc..
/api/files/123.json returns file number 123 in JSON format.
A file contains fields such as "name", "id", "author", "lastmodified", etc..
How should I implement the fact that a file could be downloaded ?
I have several options :
1. the octect-stream representation of the file resource can be considered similar to the JSON and XML ones, so I can make /api/files/123.data to get the stream of the file
2. all of my resources have a "url" attribute that points to their API URL, but I could make an exception for the "files", for whom the url coud refer to the downloadable version of the file, like so : { "file": { "id": 123, "url": "/getFile.ashx?id=123" } } but I don't like this approach
3. Any other idea is welcomed !
Thanks a lot.