Caching Images - WHOIGit/ndsf-sealog-client GitHub Wiki

How Sealog serves files

The Sealog server might send a reference to an image like so:

{
    "data_name": "filename",
    "data_value": "/J2-1245/SciCam/SciCam.20200202_070035573.jpg"
}

This path is relative to the server's IMAGE_PATH configuration variable, the directory on the filesystem where images are saved, in path_constants.js.

The files in IMAGE_PATH are served by the Sealog server by this route with the URL given by IMAGE_ROUTE, namely /files/images. Thus, the above image would be served at

https://ndsfdh4-vm.whoi.edu:9443/sealog-server/files/images/J2-1245/SciCam/SciCam.20200202_070035573.jpg

The web client independently needs to know this IMAGE_ROUTE to reconstruct the path fragment it receives to the full URL. It would be best if Sealog server provided this information to the client, but instead it is configured in the client_config.js file. Confusingly, it is also called IMAGE_PATH, although it doesn't have the same meaning as the server's variable of the same name.

To fully reconstruct the URL, the client performs a concatenation like:

API_ROOT_URL + IMAGE_PATH + '/' + path.basename

Oddly, this path.basename means that only the last path component is used, e.g., SciCam.20200202_070035573.jpg.