Skip to content
W. Scott Meeks edited this page Sep 6, 2019 · 5 revisions

Table of Contents

  1. Index
  2. Create
  3. Update
  4. Destroy

1. Index

Description

List images

Url

GET api/v1/{imageable_type}/{imageable_id}/images
e.g., api/v1/assets/A3CFFNMLECIAD/images

Request

Request must contain following parameters in URL:

  • imageable_type string [REQUIRED]
  • imageable_id string [REQUIRED]

Response

If successful, will return image array. For example:

{
    "status": "success",
    "data": {
        "images": [
            {
                "object_key": "A3CN063DDED2",
                "description": "test image 1"
                "url": "http://sample.com/test_image_1.png"
            },
            {
                "object_key": "A4CN0D3DDEF2",
                "description": "test image 2"
                "url": "http://sample.com/test_image_2.png"
            }
        ]
    }
}

2. Create

Description

Upload one image. This version of the API uses base64 to encode and transfer the image data.

Url

POST api/v1/{imageable_type}/{imageable_id}/images
e.g., api/v1/assets/A3CFFNMLECIAd/images

Request

Request must contain the following parameters in the URL:

  • imageable_type string [REQUIRED]
  • imageable_id string [REQUIRED]

And the following parameters in the POST Body:

  • image base64 string [REQUIRED]
  • original_filename string [REQUIRED]
  • content_type string [REQUIRED] (e.g "image/jpeg")
  • description string [REQUIRED] (can be empty string)
  • image_classification_id integer [OPTIONAL]
  • compass_point string [OPTIONAL] (N NE E SE S SW W NW)
  • latitude float [OPTIONAL]
  • longitude float [OPTIONAL]

Response

If successful, will return uploaded image data. For example:

{
    "status": "success",
    "data": {
        "image": {
            "object_key": "A3CN063DDED2",
            "description": "test image 1"
            "url": "http://sample.com/test_image_1.png"
        }
    }
}

3. Update

Description

Update one image

Url

PATCH/PUT api/v1/{imageable_type}/{imageable_id}/images/{id}
e.g., api/v1/assets/A3CFFNMLECIAd/images/A3CN063DDED2

Request

Request must contain following parameters in URL:

  • imageable_type string [REQUIRED]
  • imageable_id string [REQUIRED]
  • id _string [required]

Response

If successful, will return updated image data. For example:

{
    "status": "success",
    "data": {
        "image": {
            "object_key": "A3CN063DDED2",
            "description": "updated test image 1"
            "url": "http://sample.com/test_image_1.png"
        }
    }
}

4. Destroy

Description

Delete one image

Url

DELETE api/v1/{imageable_type}/{imageable_id}/images/{id}
e.g., api/v1/assets/A3CFFNMLECIAd/images/A3CN063DDED2

Request

Request must contain following parameters in URL:

  • imageable_type string [REQUIRED]
  • imageable_id string [REQUIRED]
  • id _string [required]

Response

If successful, will return empty data hash. For example:

{
    "status": "success",
    "data": {}
}