This is a small repo that implements a streaming based file server mainly directed towards GeoTIFF and FlatGeoBuffer files. The server exposes a few REST endpoints that allow for (hopefully) efficient streaming of geographic files, subsets of those files and reprojections ( and any combiination thereof ) to a client.
Geographic file servers exist (a la GeoServer) and are Very good at what they do - but sometimes it's too much. For a portion of a project where all you want to do is efficiently stream some spatial files stored on disk to some client ( maybe put it behind Nginx and add some rate limits ) and allow for reprojection/subsetting on the fly - GeoServer can feel like overkill. This gets that portion up and running in 5 minutes, hopefully.
Clone the repo, run npm run build and npm run postbuild and build the docker image, thats it.
When you run the container - bind the directry you want to serve files out of on your host to the /files path in the container - any files/directories there will be accessible to the server.
The server runs on port 3000 in the container.
E.g.
docker run mycontainer -p 3000:3000 -v /path/to/my/files:/filesAnd you should be off to the races.
The server is Super simple and only exposes 3 endpoints (right now), the streaming endpoint, an endpoint to list files/directories and a healthcheck.
Method GET
Query Params
{
file : string | string[], //the file(s) to subset/transform
bbox? : [ minx , miny , maxx , maxy ], #in EPSG:4326
reprojectTo? : string //epsg code,
readme? : boolean //if exists we push a zip with a simple readme auto generated ( this really can just be used to trick the browser into starting the download before the stream has started, can be nice with large TIFF files)
}Returns A zipfile stream with your data in it, reprojected, subsetted to a BBOX and so forth
Method GET
Query Params
{
dir : string #the subdirectory to list ( or "/" for root of serving directory)
}Returns
{
"name": string,
"size": number, #in bytes
"isDir": boolean,
"path": string
}[]Method GET
Returns status code 200
The server runs a subprocess or so per file stream (technically 2 in sequence if its raster as we have to eprsist a tmp to disk). This means that if you find yourself in a low core count env or one with high throughput. you can potentially thrash the main thread (and the others) pretty easily. This will be fixed in the future with a soft user-set concurrency limit.