Skip to content

Upload Image

Jana Rajakumar edited this page Feb 23, 2018 · 6 revisions

This feature is disabled by default. Follow these steps to enable.

Enable Image Upload

  • Config the following in the app settings.
LORIS_DIRECTORY = "/home/rajakumaj/IIIFAPI/Images/" # The base path of the system directory where LORIS stores all images. Overide this vale in production.
LORIS_URL = 'https://iiif.library.utoronto.ca/image/v2/' # The base url for images being served from Loris. Overide this vale in production.
  • Add the following snippet in the swagger.json open api specification found under static/templates folder. This would add the endpoint to the interactive documentation found at the root url.
       {"/images":{
            "post":{
                "description":"",
                "summary":"Upload an IIIF Image",
                "tags":[
                    "IIIF_Image_API"
                ],
                "operationId":"UploadImage",
                "produces":[
                    "application/json"
                ],
                "parameters":[
                    {
                        "name":"Authorization",
                        "in":"header",
                        "required":true,
                        "type":"string",
                        "description":""
                    },
                    {
                        "name":"Body",
                        "in":"body",
                        "required":true,
                        "description":"",
                        "schema":{
                            "$ref":"#/definitions/UploadImageRequest"
                        }
                    }
                ],
                "responses":{
                    "201":{
                        "description":"",
                        "schema":{
                            "$ref":"#/definitions/UploadImageResponse"
                        },
                        "examples":{
                            "application/json":{
                                "url":"https://iiif.library.utoronto.ca/image/v2/shibu.jpg"
                            }
                        }
                    }
                }
            }
        }
    }

Image Upload

Images can be uploaded by sending a POST request to /images with the filename and the base64 encoded imageContent.

{
  "filename": "shiba.jpg",
  "imageContent": "/9j/4AAQSkZJRgABAQEASABIAAD/2wBDAAQDAwMDAgQRsYHRYYGRj/2wBDAQQEBAYFBgsGBgsYEAYGBj/wAARCASwBLADAREAAhEBAxE...."
}

The images will be uploaded to the local directory where LORIS is configured to serve them. These settings are configured by the following variables.

LORIS_DIRECTORY = "/home/rajakumaj/IIIFAPI/Images/" # The base path of the system directory where LORIS stores all images. Overide this vale in production.
LORIS_URL = 'https://iiif.library.utoronto.ca/image/v2/' # The base url for images being served from Loris. Overide this vale in production.

(Example): Given the above settings and request, the image will be uploaded to /home/rajakumaj/IIIFAPI/Images/shiba.jpg and the client will receive the following response.

{
  "url": "https://iiif.library.utoronto.ca/image/v2/shibu.jpg"
}

Reference: https://iiif.library.utoronto.ca/presentation/v2/#!/IIIF_Image_API/UploadImage

Clone this wiki locally