use of org.vitrivr.cineast.api.rest.resolvers.FileSystemObjectResolver in project cineast by vitrivr.
the class APIEndpoint method registerServingRoutes.
/**
* If configured, this registers two special routes that serve the media objects as media content and additionally a thumbnails endpoint for them.
*/
private void registerServingRoutes(final Javalin service, final APIConfig config) {
if (config.getServeContent()) {
service.get("/thumbnails/{id}", new ResolvedContentRoute(new FileSystemThumbnailResolver(new File(Config.sharedConfig().getApi().getThumbnailLocation()))));
/* The VBS database in-use is broken, this is the hack to circumvent object paths being wrong */
FileSystemObjectResolver fsor;
if (config.isObjectsFilesAreIDed()) {
fsor = new FileSystemObjectResolver(new File(Config.sharedConfig().getApi().getObjectLocation()), new MediaObjectReader(Config.sharedConfig().getDatabase().getSelectorSupplier().get()), ((baseDir, object) -> {
// String ext = object.getPath().substring(object.getPath().lastIndexOf('.'));
String ext = "." + Config.sharedConfig().getApi().getVideoExtension();
return new File(baseDir, object.getObjectId() + ext);
}));
} else {
fsor = new FileSystemObjectResolver(new File(Config.sharedConfig().getApi().getObjectLocation()), new MediaObjectReader(Config.sharedConfig().getDatabase().getSelectorSupplier().get()));
}
service.get("/objects/{id}", new ResolvedContentRoute(fsor));
}
}
Aggregations