Image API - StudioAquatan/django_sample_api GitHub Wiki

/api/v1/images

method header(Content-Type) param response
GET application/json - HTTP_200_OK
POST multipart/form-data file: Upload image
name: File name
HTTP_201_CREATED
see /api/v1/images/<pk:int>

GET

{
  "count": 2,
  "next": "url to next page or null",
  "previous": "url to next page or null",
  "results": [
    {
        "pk": 2,
        "name": "table",
        "file": "http://example.com/media/images/fd883ff293434e7db82380bc6906a212.JPG",
        "created_at": "2018-05-26T21:21:17.733848+09:00"
    },
    {
        "pk": 1,
        "name": "test",
        "file": "http://example.com/media/images/1c52d898d1db4db689fb38a406bd1cd1.jpeg",
        "created_at": "2018-05-26T21:11:34.686626+09:00"
    }
  ]
}

POST

multipart/form-dataで画像を送信する.

/api/v1/images/<pk:int>/

primary keyで指定する.

method header(Content-Type) param response
GET application/json - HTTP_200_OK
PUT multipart/form-data file: Upload image
name: File name
HTTP_200_OK
PATCH multipart/form-data specify field to update HTTP_200_OK
DELETE - - HTTP_204_NO_CONTENT
{
    "pk": 1,
    "name": "test",
    "file": "http://example.com/media/images/1c52d898d1db4db689fb38a406bd1cd1.jpeg",
    "created_at": "2018-05-26T21:11:34.686626+09:00"
}

/api/v1/base64images/

Base64でエンコードして文字列化した画像を送信するAPI(こっちの方が使いやすいか?).モデル自体は /api/v1/images/と共通なので,どちらでアップロードしたデータも見れる.

method header(Content-Type) param response
GET application/json - HTTP_200_OK
POST application/json file: Base64 text
name: File name
HTTP_201_CREATED

GET

{
  "count": 2,
  "next": "url to next page or null",
  "previous": "url to next page or null",
  "results": [
    {
        "pk": 2,
        "name": "table",
        "file": "http://example.com/media/images/fd883ff293434e7db82380bc6906a212.JPG",
        "created_at": "2018-05-26T21:21:17.733848+09:00"
    },
    {
        "pk": 1,
        "name": "test",
        "file": "http://example.com/media/images/1c52d898d1db4db689fb38a406bd1cd1.jpeg",
        "created_at": "2018-05-26T21:11:34.686626+09:00"
    }
  ]
}

POST

{
    "file": "iVBORw0KGgoAAAANSUhEUgAACOYAAAVKCAYAAABHT+bMAAAgAElEQVR4nOy9T68lS3If9ovMqjrn\\nd...",
    "name": "file title"
}

これをPOSTする

⚠️ **GitHub.com Fallback** ⚠️