Class FileServerUtility

java.lang.Object
com.pixelservices.flash.components.fileserver.FileServerUtility

public class FileServerUtility extends Object
  • Constructor Details

    • FileServerUtility

      public FileServerUtility()
  • Method Details

    • registerAllSubdirectories

      public static void registerAllSubdirectories(Path startPath, WatchService watchService) throws IOException
      Registers the given directory and all its subdirectories with the provided WatchService.
      Throws:
      IOException
    • startDirectoryWatcher

      public static void startDirectoryWatcher(Path rootPath, FileServerUtility.FileWatcherCallback callback)
      Starts a directory watcher on the given rootPath. For every watch event, the callback is invoked. Note: This method blocks the current thread.
    • autodetectSPA

      public static boolean autodetectSPA(Path dirPath)
      Attempts to auto-detect if the given directory is a modern SPA (e.g. React, Next.js, Svelte). This method checks for the presence of an index.html along with either an asset-manifest.json or next.config.js.
    • rewriteHtml

      public static String rewriteHtml(String htmlContent, String endpoint)
      Rewrites HTML content by prefixing static asset URLs with the given endpoint.
    • rewriteJs

      public static String rewriteJs(String jsContent, String endpoint)
      Rewrites JavaScript content by prefixing asset URLs with the given endpoint.
    • rewriteRoute

      public static String rewriteRoute(String route, String endpoint)
      Rewrites a route by prefixing it with the given endpoint if it isn’t already.
    • getContentType

      public static String getContentType(String fileName)