照片数据
金色童年
创建照片
上传后创建一个照片记录
Method and URL Structure
Method |
Resource URL |
POST |
/photograph/create/ |
Request Data
Name |
Description |
Required |
Default |
title |
标题 |
NO |
|
desc |
描述 |
NO |
|
file_url |
上传得到的 url |
YES |
|
taken_date |
拍摄日期 |
NO |
|
author |
作者 |
NO |
|
Request
{
"title": "xiaoming's photo",
"desc": u"南柯郡汶汶乡大槐树",
"file_url": "http://www.example.com/1.jpg",
"taken_date": "2016-07-01 11:00:03",
'author': u'布可朔夫',
}
cURL Example
curl -X PUT -H 'Authorization: Token 9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b'\
-H 'Content-Type: Application/json' --data '{....}' http://localhost/photograph/create/
Response Data
Name |
Description |
pk |
图片 ID |
title |
照片标题 |
desc |
照片描述 |
file_url |
文件路径 |
taken_date |
拍摄日期 |
author |
文件的大图、小图 |
Reponse
{
"pk": 313,
"title": "xiaoming's photo",
"desc": u"南柯郡汶汶乡大槐树",
"file_url": {
"url": "http://example.com/1.jpg",
"url_150x150": "http://example.com/1.jpg-150x150"
},
"taken_date": "2016-07-01 11:00:03",
'author': u'布可朔夫',
}
添加照片到相册
Method and URL Structure
Method |
Resource URL |
POT |
/photograph/add/album/ |
Request Data
Name |
Description |
Required |
Default |
album |
相册 pk |
YES |
|
photograph |
照片 pk |
YES |
|
Request
{
"album": 99,
'photograph': 234,
}
cURL Example
curl -X POST -H 'Authorization: Token 9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b'
--data '{...}'
http://localhost/photograph/add/album/
Reponse Data
Name |
Description |
album |
相册 id |
photograph |
图片 id |
Reponse
{
"album": 99,
"photograph", 234,
}
从相册里移除照片
Method and URL Structure
Method |
Resource URL |
DELETE |
/photograph/rm/album/ |
Request Data
Name |
Description |
Required |
Default |
album |
相册 pk |
YES |
|
photograph |
照片 pk |
YES |
|
Request
{
"album": 99,
'photograph': 234,
}
cURL Example
curl -X POST -H 'Authorization: Token 9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b'
--data '{...}'
http://localhost/photograph/add/album/
搜索照片
Method and URL Structure
Method |
Resource URL |
GET |
/photograph/search/ |
搜索如下字段
Name |
Description |
title |
标题 |
taken_date |
拍摄日期 |
taken_location |
拍摄地点 |
desc |
描述 |
Request Parameters
Name |
Description |
Required |
Default |
searching |
关键字 |
YES |
|
cURL Example
curl -H 'Authorization: Token 9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b' \
http://localhost/photograph/search/?searching=汶汶乡
Response Data
Name |
Description |
pk |
图片 ID |
title |
照片标题 |
desc |
照片描述 |
file_url |
文件路径 |
taken_date |
拍摄日期 |
author |
文件的大图、小图 |
album |
加入过的相册信息 |
Response
{
"count":1,
"next":null,
"previous":null,
"results":[{
"pk":27,
"title":"xiaoming's photo",
"desc":"南柯郡汶汶乡大槐树",
"file_url": {
"url": "http://example.com/1.jpg,
"url_150x150": "http://example.com/1.jpg-150x150"
},
"taken_date":"2016-07-01T11:00:03",
"author":"布可朔夫",
"created":"2016-10-18T00:40:56.922265",
"albums":[{
"album":"31",
"name":"xiaoming's album",
"created":"2016-10-18T00:40:56.924337"
}]
}]
}