From 8f4d1c67d3996657c57ed868f34da4066095480c Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Fri, 2 Feb 2018 12:39:22 +0500 Subject: Add switch to enable media web access --- src/org/traccar/web/WebServer.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/org') diff --git a/src/org/traccar/web/WebServer.java b/src/org/traccar/web/WebServer.java index 88b38c1ab..5c3fc8aaa 100644 --- a/src/org/traccar/web/WebServer.java +++ b/src/org/traccar/web/WebServer.java @@ -167,12 +167,14 @@ public class WebServer { servletHandler.addServlet(new ServletHolder(new AsyncSocketServlet()), "/socket"); - ServletHolder servletHolder = new ServletHolder("media", DefaultServlet.class); - servletHolder.setInitParameter("resourceBase", config.getString("media.path")); - servletHolder.setInitParameter("dirAllowed", config.getString("media.directoryAllow", "false")); - servletHolder.setInitParameter("pathInfoOnly", "true"); - servletHandler.addServlet(servletHolder, "/media/*"); - servletHandler.addFilter(MediaFilter.class, "/media/*", EnumSet.allOf(DispatcherType.class)); + if (config.getBoolean("media.web.enable")) { + ServletHolder servletHolder = new ServletHolder("media", DefaultServlet.class); + servletHolder.setInitParameter("resourceBase", config.getString("media.path")); + servletHolder.setInitParameter("dirAllowed", config.getString("media.web.directoryAllow", "false")); + servletHolder.setInitParameter("pathInfoOnly", "true"); + servletHandler.addServlet(servletHolder, "/media/*"); + servletHandler.addFilter(MediaFilter.class, "/media/*", EnumSet.allOf(DispatcherType.class)); + } ResourceConfig resourceConfig = new ResourceConfig(); resourceConfig.registerClasses(JacksonFeature.class, ObjectMapperProvider.class, ResourceErrorHandler.class); -- cgit v1.2.3