Update multiple granules in GeoServer image mosaic store via Rest API

I have an image mosaic store that handles .tiff with the TIME dimension enabled. Every hour I add 240 new files and remove the older ones. Currently I’m updating this store using the REST API and adding one file at a time using the “/workspaces/{workspace}/coveragestores/{store}/external.imagemosaic” endpoint where I send the path of the file as “file:/path/to/file_20230911XXXXX.tiff”

This process works but I need to issue 240 requests to the server and I was trying to find a way to do this update process in bulk just once.

I’ve tried sending the path of multiple files as a list, but I receive:

org.geoserver.rest.RestException 400 BAD_REQUEST: Failed to locate the input file file:/app/temperature/temperature_20230707T120000.tiff
file:/app/temperature/temperature_20230707T130000.tiff
file:/app/temperature/temperature_20230707T140000.tiff
file:/app/temperature/temperature_20230707T150000.tiff

From this It seems like it can only receive a single file.

From the documentation it also mentions “Creates or modified a single coverage store by uploading its raster data files. Multi-file stores like mosaic can be created by uploading a zip file and setting the content type to “application/zip” “. But in this case it is expecting that I send the files via the network which I prefer not to as each file is around 1GB and also are already reachable by GeoServer. In this case I would like to send just the path as (file:/path/to/file.tiff) which is possible when I update just one file

Any guidance is appreciated,


EDIT: I’ve just found that you can send the base directory and GeoServer will re-harvest the files and add the NEW files to the index (Source: https://docs.geoserver.org/2.23.x/en/user/rest/imagemosaic.html#updating-an-image-mosaic-contents)

But it seems that this options does not remove old granules even if the file that they are linked to is no longer available. Is there another option that handles this scenario? If not I’ll just issue a delete command before the reharvesting

Thanks,

Leave a Comment