I am working on building a PHP/Zend REST webservice and one of its “methods” is to retrieve a user profile (I would go let’s say site.com/user/profile). All the user data is pretty much encoded as string (name, description, dob, …) but I dont know how should I retrieve their image. What would be the best way to bring the user image and still be RESTfully complied? Should I have a specific method for the image or is there a way I could bring it all the data at once?
The pictures could be either saved in the file system or in the database, this should not matter on the implementation.
couple of options:
– Use accept type header on the request to the same Uri. (site.com/user/profile), so a get with accept type json will bring their data, with jpg it would return the image.
– add additional resource identifier for the image, such as /user/profile/picture. The Uri for this resource should be supplied in the response for /user/profile
depends how you think of the picture, is it a different representation of the same resource, or a new resource.