我是开发webservice的新手,我的想法是构建一个基于PHP的REST API。 这使得CRUD图像文件成为可能,例如图像/ test.jpg放在。
是否可以通过REST Web服务获取图像?如果是,那怎么样? 或者仅提供json响应的Web服务?
我更喜欢没有框架的方法,因为我想学习。
我的路线:
// GET
/api/images # Get alle images
/api/images/1 # Get images based on primary key
// PUT
/api/images/1 # Update images based on primary key
// POST
/api/images # Add a new image
// DELETE
/api/images/1 # Delete images based on primary key
/api/images/1
{
"filename": "example.jpg",
"filepath": "www.example.com/images/example.jpg",
"htmlAlt": "Example Image",
}
或者这个版本更好
{
"filename": "example.jpg",
"filepath": "images/example.jpg",
"htmlAlt": "Example Image",
}
答案 0 :(得分:-1)
Is possible to get images over a REST webservice?
Yes.
If yes, then how?
You make a GET request to the URL which represents the image. The server sends back an image.
(Said server might also support PUT requests to upload new images, DELETE requests to remove them, and so on).
Or is a webservice only for json responses provided?
A webservice provides whatever kind of data its author wants to provide.