[关闭]
@fuyb1986 2017-05-11T06:53:06.000000Z 字数 2325 阅读 620

照片数据

金色童年


创建照片

上传后创建一个照片记录

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

  1. {
  2. "title": "xiaoming's photo",
  3. "desc": u"南柯郡汶汶乡大槐树",
  4. "file_url": "http://www.example.com/1.jpg",
  5. "taken_date": "2016-07-01 11:00:03",
  6. 'author': u'布可朔夫',
  7. }

cURL Example

  1. curl -X PUT -H 'Authorization: Token 9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b'\
  2. -H 'Content-Type: Application/json' --data '{....}' http://localhost/photograph/create/

Response Data

Name Description
pk 图片 ID
title 照片标题
desc 照片描述
file_url 文件路径
taken_date 拍摄日期
author 文件的大图、小图

Reponse

  1. {
  2. "pk": 313,
  3. "title": "xiaoming's photo",
  4. "desc": u"南柯郡汶汶乡大槐树",
  5. "file_url": {
  6. "url": "http://example.com/1.jpg",
  7. "url_150x150": "http://example.com/1.jpg-150x150"
  8. },
  9. "taken_date": "2016-07-01 11:00:03",
  10. 'author': u'布可朔夫',
  11. }

添加照片到相册

Method and URL Structure

Method Resource URL
POT /photograph/add/album/

Request Data

Name Description Required Default
album 相册 pk YES
photograph 照片 pk YES

Request

  1. {
  2. "album": 99,
  3. 'photograph': 234,
  4. }

cURL Example

  1. curl -X POST -H 'Authorization: Token 9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b'
  2. --data '{...}'
  3. http://localhost/photograph/add/album/

Reponse Data

Name Description
album 相册 id
photograph 图片 id

Reponse

  1. {
  2. "album": 99,
  3. "photograph", 234,
  4. }

从相册里移除照片

Method and URL Structure

Method Resource URL
DELETE /photograph/rm/album/

Request Data

Name Description Required Default
album 相册 pk YES
photograph 照片 pk YES

Request

  1. {
  2. "album": 99,
  3. 'photograph': 234,
  4. }

cURL Example

  1. curl -X POST -H 'Authorization: Token 9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b'
  2. --data '{...}'
  3. 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

  1. curl -H 'Authorization: Token 9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b' \
  2. http://localhost/photograph/search/?searching=汶汶乡

Response Data

Name Description
pk 图片 ID
title 照片标题
desc 照片描述
file_url 文件路径
taken_date 拍摄日期
author 文件的大图、小图
album 加入过的相册信息

Response

  1. {
  2. "count":1,
  3. "next":null,
  4. "previous":null,
  5. "results":[{
  6. "pk":27,
  7. "title":"xiaoming's photo",
  8. "desc":"南柯郡汶汶乡大槐树",
  9. "file_url": {
  10. "url": "http://example.com/1.jpg,
  11. "url_150x150": "http://example.com/1.jpg-150x150"
  12. },
  13. "taken_date":"2016-07-01T11:00:03",
  14. "author":"布可朔夫",
  15. "created":"2016-10-18T00:40:56.922265",
  16. "albums":[{
  17. "album":"31",
  18. "name":"xiaoming's album",
  19. "created":"2016-10-18T00:40:56.924337"
  20. }]
  21. }]
  22. }
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注